cairodriver.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Cairo driver</title>
  5. <meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
  6. <link rel="stylesheet" href="grassdocs.css" type="text/css">
  7. </head>
  8. <body bgColor=white>
  9. <img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
  10. <h2>NAME</h2>
  11. <em><b>Cairo driver</b></em> - display driver for bitmap or vector
  12. output using the Cairo graphics library.
  13. <h2>DESCRIPTION</h2>
  14. The Cairo driver generates PNG, BMP, PPM, PS, PDF or SVG images by
  15. GRASS display commands, using the
  16. <a href="http://www.cairographics.org/">Cairo graphics library</a>.
  17. The image format is selected from the extension of the output file.
  18. The Cairo driver is used for GRASS display commands by default if
  19. available, otherwise <em><a href="pngdriver.html">PNG driver</a></em>
  20. is used.
  21. <h2>USAGE</h2>
  22. <h3>Environment variables</h3>
  23. The Cairo driver can be enabled by
  24. setting <b>GRASS_RENDER_IMMEDIATE</b> variable, eg.
  25. <div class="code"><pre>
  26. export GRASS_RENDER_IMMEDIATE=cairo
  27. </pre></div>
  28. Several environment variables affect the operation of the Cairo driver:
  29. <ul>
  30. <li><b>GRASS_WIDTH=xxx</b><br>
  31. the width of the image map (default is 640).
  32. </li>
  33. <li><b>GRASS_HEIGHT=yyy</b><br>
  34. the height of the image map (default is 480).
  35. </li>
  36. <li><b>GRASS_BACKGROUNDCOLOR=RRGGBB</b><br>
  37. specifies the background color to use in RGB notation (hex or
  38. R:G:B values). Named colors are also supported. Default
  39. is <b>FFFFFF</b> (white).
  40. </li>
  41. <li><b>GRASS_TRANSPARENT=[TRUE|FALSE]</b><br>
  42. sets transparent background on (TRUE) or off (FALSE, default).
  43. </li>
  44. <li><b>GRASS_ANTIALIAS</b><br> can be <em>default</em>,
  45. <em>none</em>, <em>gray</em>, or <em>subpixel</em>, corresponding to
  46. <a href="http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t">cairo_antialias_t</a>
  47. </li>
  48. <li><b>GRASS_PNGFILE=filename</b><br>
  49. the name and format of the resulting image file, default is
  50. <tt>map.png</tt>.<br>
  51. The image format is determined from the file extension.<br>
  52. Supported bitmap formats:
  53. <ul>
  54. <li><b>.png</b> - Portable Network Graphics (PNG)</li>
  55. <li><b>.bmp</b> - Windows Bitmap (BMP, 32-bpp)
  56. (these are not readable by some older viewers)</li>
  57. <li><b>.ppm</b> - Portable Pixmap (PPM + PGM for alpha channel)</li>
  58. </ul>
  59. Supported vector formats:
  60. <ul>
  61. <li><b>.pdf</b> - Portable Document Format (PDF)</li>
  62. <li><b>.ps</b> - PostScript (PS)</li>
  63. <li><b>.svg</b> - Scalable Vector Graphics (SVG)</li>
  64. </ul>
  65. (Note: Some formats may not be available, depending on your platform and
  66. the Cairo library that GRASS was built with.)
  67. </li>
  68. <li><b>GRASS_PNG_READ</b><br>
  69. if <tt>TRUE</tt>, the Cairo driver will initialize the image from
  70. the contents of GRASS_PNGFILE.<br>
  71. (<em>Note: This is only supported for bitmap formats</em>)
  72. </li>
  73. <li><b>GRASS_PNG_MAPPED</b><br>
  74. if <tt>TRUE</tt>, the Cairo driver will map GRASS_PNGFILE as its framebuffer,
  75. rather than using memory.<br>
  76. (<em>Note: This only works with BMP files.</em>)
  77. </li>
  78. <li><b>GRASS_CAIRO_SCREEN</b><br>
  79. defines Cairo screen
  80. </li>
  81. <li><b>GRASS_CAIRO_VISUAL</b><br>
  82. defines Cairo visual
  83. </li>
  84. </ul>
  85. <h3>Examples</h3>
  86. Example: using the driver to generate a PNG file (bash-syntax):
  87. <div class="code"><pre>
  88. export GRASS_RENDER_IMMEDIATE=cairo
  89. export GRASS_PNGFILE=nc_spm.png
  90. export GRASS_WIDTH=800
  91. export GRASS_HEIGHT=800
  92. export GRASS_PNG_READ=TRUE
  93. g.region rast=elevation
  94. d.rast map=elevation
  95. d.vect map=streams width=1 color=blue fcolor=aqua type=area,line
  96. d.vect map=roadsmajor width=2
  97. </pre></div>
  98. <!-- TODO: why does it generate rasterized output?
  99. Example: using the driver to generate a PDF file with a vector map (bash-syntax):
  100. <div class="code"><pre>
  101. export GRASS_RENDER_IMMEDIATE=cairo
  102. export GRASS_PNGFILE=nc_spm.pdf
  103. export GRASS_WIDTH=800
  104. export GRASS_HEIGHT=800
  105. g.region vect=roadsmajor
  106. # activate vector font
  107. d.font Vera
  108. d.vect map=roadsmajor layer=1 display=shape,attr attrcolumn=ROAD_NAME lcolor=0:90:255
  109. </pre></div>
  110. -->
  111. Example: using the driver to generate a PDF file with a raster map (bash-syntax):
  112. <div class="code"><pre>
  113. export GRASS_RENDER_IMMEDIATE=cairo
  114. export GRASS_PNGFILE=nc_spm.pdf
  115. export GRASS_WIDTH=800
  116. export GRASS_HEIGHT=800
  117. g.region rast=elevation
  118. d.rast map=elevation
  119. </pre></div>
  120. <h2>NOTES</h2>
  121. The driver is still in development. Enable it by specifying
  122. <code>--with-cairo</code> when configuring GRASS. This
  123. requires a reasonably recent version of the Cairo libraries
  124. and a working <tt>pkg-config</tt>.
  125. <p>Antialiasing is enabled by default for bitmap formats. There is
  126. currently no way of disabling this.
  127. <p>The resolution of the output images is defined by current region
  128. extents. Use <tt>g.region -p</tt> to get the number of rows and cols
  129. and use the environment variables to set the image size. If you would
  130. like a larger image, multiply both rows and cols by the same whole
  131. number to preserve the aspect ratio.
  132. <p>Cairo supports true vector format output whenever possible. However,
  133. if the selected format doesn't support a necessary feature, Cairo may
  134. fall back on rendering a bitmap representation of the image wrapped in
  135. the selected vector format.
  136. <h2>SEE ALSO</h2>
  137. <em>
  138. <a href="pngdriver.html">PNG driver</a>,
  139. <a href="psdriver.html">PS driver</a>,
  140. <a href="htmldriver.html">HTML driver</a>,
  141. <a href="variables.html">variables</a>
  142. </em>
  143. <p>
  144. <em>
  145. <a href="d.rast.html">d.rast</a>,
  146. <a href="d.vect.html">d.vect</a>,
  147. <a href="d.mon.html">d.mon</a>,
  148. <a href="d.erase.html">d.erase</a>,
  149. <a href="d.redraw.html">d.redraw</a>
  150. </em>
  151. <h2>AUTHOR</h2>
  152. Lars Ahlzen &lt;<i>lars (at) ahlzen.com</i>&gt;<br>
  153. and the GRASS Development Team.