pngdriver.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <!-- meta page description: PNG DISPLAY DRIVER -->
  2. <em>PNG display driver</em> to create PNG, PPM, or BMP images.
  3. <h2>DESCRIPTION</h2>
  4. The PNG driver generates PNG, PPM, or BMP images from GRASS display
  5. commands. Per default PNG files are written with this driver. This
  6. driver is used by default if <em><a href="cairodriver.html">Cairo
  7. driver</a></em> is not available.
  8. <h2>USAGE</h2>
  9. <h3>Environment variables</h3>
  10. The PNG driver can be enabled by setting <b>GRASS_RENDER_IMMEDIATE</b>
  11. variable, eg.
  12. <div class="code"><pre>
  13. export GRASS_RENDER_IMMEDIATE=png
  14. </pre></div>
  15. Several environment variables affect the operation of the PNG driver:
  16. <ul>
  17. <li><b>GRASS_WIDTH=xxx</b><br>
  18. the width of the image map (default is 640).
  19. </li>
  20. <li><b>GRASS_HEIGHT=yyy</b><br>
  21. the height of the image map (default is 480).
  22. </li>
  23. <li><b>GRASS_BACKGROUNDCOLOR=RRGGBB</b><br>
  24. specifies the background color to use in RGB notation (hex or
  25. R:G:B values). Named colors are also supported. Default
  26. is <b>FFFFFF</b> (white).
  27. </li>
  28. <li><b>GRASS_TRANSPARENT=[TRUE|FALSE]</b><br>
  29. sets transparent background on (TRUE) or off (FALSE, default).
  30. </li>
  31. <li><b>GRASS_TRUECOLOR=[TRUE|FALSE]</b><br>
  32. sets true-color support. Default is TRUE.
  33. </li>
  34. <li><b>GRASS_PNGFILE=filename</b><br>
  35. the filename to put the resulting image in, default is <tt>map.png</tt>.
  36. If you set GRASS_PNGFILE to a filename which ends in ".ppm", a PPM
  37. file will be created (with alpha channel stored in a PGM image, if applicable).
  38. If you set GRASS_PNGFILE to a filename which ends in ".bmp", a 32-bpp
  39. BMP file will be created (these are not readable by some older viewers).
  40. </li>
  41. <li><b>GRASS_PNG_COMPRESSION=[0|1|9]</b><br>
  42. compression level of PNG files (0 = none, 1 = fastest, 9 = best, default is 6)
  43. </li>
  44. <li><b>GRASS_PNG_READ</b><br>
  45. if <tt>TRUE</tt>, the PNG driver will initialize the image from
  46. the contents of GRASS_PNGFILE.
  47. </li>
  48. <li><b>GRASS_PNG_MAPPED</b><br>
  49. if <tt>TRUE</tt>, the PNG driver
  50. will map GRASS_PNGFILE as its framebuffer, rather than using
  51. memory. This only works with BMP files.
  52. </li>
  53. </ul>
  54. <h3>Example</h3>
  55. <div class="code"><pre>
  56. export GRASS_RENDER_IMMEDIATE=png
  57. export GRASS_TRUECOLOR=TRUE
  58. g.region rast=elevation
  59. d.rast elevation
  60. d.vect roadsmajor color=red
  61. </pre></div>
  62. This writes a file named <tt>map.png</tt> in your current directory.
  63. <h2>NOTES</h2>
  64. The PNG driver uses the libpng (see
  65. the <a href="http://www.libpng.org/pub/png/">libpng</a> home page) and
  66. zlib (see the
  67. <a href="http://www.zlib.net">zlib</a> home page), all which needs to
  68. be installed for the PNG driver to work (it's worth it).
  69. <p>The resolution of the output images is defined by current region
  70. extents. Use <tt>g.region -p</tt> to get the number of rows and cols
  71. and use the environment variables to set the image size. If you would
  72. like a larger image, multiply both rows and cols by the same whole
  73. number to preserve the aspect ratio.
  74. <p>Further PNG file processing (e.g. quantization to 1 bit for monochrome
  75. images) can be done with <tt>pnmquant</tt> of
  76. the <a href="http://netpbm.sourceforge.net/">netpbm</a> tools.
  77. <h2>SEE ALSO</h2>
  78. <em>
  79. <a href="cairodriver.html">Cairo driver</a>,
  80. <a href="psdriver.html">PS driver</a>,
  81. <a href="htmldriver.html">HTML driver</a>,
  82. <a href="variables.html">variables</a>
  83. <br><br>
  84. <a href="d.rast.html">d.rast</a>,
  85. <a href="d.vect.html">d.vect</a>,
  86. <a href="d.mon.html">d.mon</a>,
  87. <a href="d.erase.html">d.erase</a>,
  88. <a href="d.redraw.html">d.redraw</a>
  89. </em>
  90. <h2>AUTHOR</h2>
  91. Original version: Per Henrik Johansen &lt;<i>phj (at)
  92. norgit.no</i>&gt; <!-- broken link <I><a href="http://www.norgit.no">NORGIT AS</a></i> -->
  93. <br>
  94. Rewritten by: Glynn Clements, 2003
  95. <p><i>Last changed: $Date$</i>