TIFFRGBAImage.3tiff.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <!-- Creator : groff version 1.18.1 -->
  2. <!-- CreationDate: Sat Feb 24 18:37:17 2007 -->
  3. <html>
  4. <head>
  5. <meta name="generator" content="groff -Thtml, see www.gnu.org">
  6. <meta name="Content-Style" content="text/css">
  7. <title>TIFFRGBAImage</title>
  8. </head>
  9. <body>
  10. <h1 align=center>TIFFRGBAImage</h1>
  11. <a href="#NAME">NAME</a><br>
  12. <a href="#SYNOPSIS">SYNOPSIS</a><br>
  13. <a href="#DESCRIPTION">DESCRIPTION</a><br>
  14. <a href="#ALTERNATE RASTER FORMATS">ALTERNATE RASTER FORMATS</a><br>
  15. <a href="#SIMULTANEOUS RASTER STORE AND DISPLAY">SIMULTANEOUS RASTER STORE AND DISPLAY</a><br>
  16. <a href="#SUPPORTING ADDITIONAL TIFF FORMATS">SUPPORTING ADDITIONAL TIFF FORMATS</a><br>
  17. <a href="#NOTES">NOTES</a><br>
  18. <a href="#RETURN VALUES">RETURN VALUES</a><br>
  19. <a href="#DIAGNOSTICS">DIAGNOSTICS</a><br>
  20. <a href="#SEE ALSO">SEE ALSO</a><br>
  21. <hr>
  22. <a name="NAME"></a>
  23. <h2>NAME</h2>
  24. <!-- INDENTATION -->
  25. <table width="100%" border=0 rules="none" frame="void"
  26. cols="2" cellspacing="0" cellpadding="0">
  27. <tr valign="top" align="left">
  28. <td width="8%"></td>
  29. <td width="91%">
  30. <p>TIFFRGBAImageOK, TIFFRGBAImageBegin, TIFFRGBAImageGet,
  31. TIFFRGBAImageEnd &minus; read and decode an image into a
  32. raster</p>
  33. </td>
  34. </table>
  35. <a name="SYNOPSIS"></a>
  36. <h2>SYNOPSIS</h2>
  37. <!-- INDENTATION -->
  38. <table width="100%" border=0 rules="none" frame="void"
  39. cols="2" cellspacing="0" cellpadding="0">
  40. <tr valign="top" align="left">
  41. <td width="8%"></td>
  42. <td width="91%">
  43. <p><b>#include &lt;tiffio.h&gt;</b></p>
  44. <!-- INDENTATION -->
  45. <p><b>typedef unsigned char TIFFRGBValue; typedef struct
  46. _TIFFRGBAImage TIFFRGBAImage;</b></p>
  47. <!-- INDENTATION -->
  48. <p><b>int TIFFRGBAImageOK(TIFF *</b><i>tif</i><b>, char</b>
  49. <i>emsg[1024]</i><b>)<br>
  50. int TIFFRGBAImageBegin(TIFFRGBAImage *</b><i>img</i><b>,
  51. TIFF*</b> <i>tif</i><b>, int</b> <i>stopOnError</i><b>,
  52. char</b> <i>emsg[1024]</i><b>)<br>
  53. int TIFFRGBAImageGet(TIFFRGBAImage *</b><i>img</i><b>,
  54. uint32_t*</b> <i>raster</i><b>, uint32_t</b> <i>width</i> <b>,
  55. uint32_t</b> <i>height</i><b>)<br>
  56. void TIFFRGBAImageEnd(TIFFRGBAImage
  57. *</b><i>img</i><b>)</b></p>
  58. </td>
  59. </table>
  60. <a name="DESCRIPTION"></a>
  61. <h2>DESCRIPTION</h2>
  62. <!-- INDENTATION -->
  63. <table width="100%" border=0 rules="none" frame="void"
  64. cols="2" cellspacing="0" cellpadding="0">
  65. <tr valign="top" align="left">
  66. <td width="8%"></td>
  67. <td width="91%">
  68. <p>The routines described here provide a high-level
  69. interface through which <small>TIFF</small> images may be
  70. read into memory. Images may be strip- or tile-based and
  71. have a variety of different characteristics: bits/sample,
  72. samples/pixel, photometric, etc. Decoding state is
  73. encapsulated in a <i>TIFFRGBAImage</i> structure making it
  74. possible to capture state for multiple images and quickly
  75. switch between them. The target raster format can be
  76. customized to a particular application&rsquo;s needs by
  77. installing custom routines that manipulate image data
  78. according to application requirements.</p>
  79. <!-- INDENTATION -->
  80. <p>The default usage for these routines is: check if an
  81. image can be processed using <i>TIFFRGBAImageOK</i>,
  82. construct a decoder state block using
  83. <i>TIFFRGBAImageBegin</i>, read and decode an image into a
  84. target raster using <i>TIFFRGBAImageGet</i>, and then
  85. release resources using <i>TIFFRGBAImageEnd</i>.
  86. <i>TIFFRGBAImageGet</i> can be called multiple times to
  87. decode an image using different state parameters. If
  88. multiple images are to be displayed and there is not enough
  89. space for each of the decoded rasters, multiple state blocks
  90. can be managed and then calls can be made to
  91. <i>TIFFRGBAImageGet</i> as needed to display an image.</p>
  92. <!-- INDENTATION -->
  93. <p>The generated raster is assumed to be an array of
  94. <i>width</i> times <i>height</i> 32-bit entries, where
  95. <i>width</i> must be less than or equal to the width of the
  96. image (<i>height</i> may be any non-zero size). If the
  97. raster dimensions are smaller than the image, the image data
  98. is cropped to the raster bounds. If the raster height is
  99. greater than that of the image, then the image data are
  100. placed in the lower part of the raster. (Note that the
  101. raster is assume to be organized such that the pixel at
  102. location (<i>x</i>,<i>y</i>) is
  103. <i>raster</i>[<i>y</i>*<i>width</i>+<i>x</i>]; with the
  104. raster origin in the <b>lower-left</b> hand corner.)</p>
  105. <!-- INDENTATION -->
  106. <p>Raster pixels are 8-bit packed red, green, blue, alpha
  107. samples. The macros <i>TIFFGetR</i>, <i>TIFFGetG</i>,
  108. <i>TIFFGetB</i>, and <i>TIFFGetA</i> should be used to
  109. access individual samples. Images without Associated Alpha
  110. matting information have a constant Alpha of 1.0 (255).</p>
  111. <!-- INDENTATION -->
  112. <p><i>TIFFRGBAImageGet</i> converts non-8-bit images by
  113. scaling sample values. Palette, grayscale, bilevel,
  114. <small>CMYK</small> , and YCbCr images are converted to
  115. <small>RGB</small> transparently. Raster pixels are returned
  116. uncorrected by any colorimetry information present in the
  117. directory.</p>
  118. <!-- INDENTATION -->
  119. <p>The parameter <i>stopOnError</i> specifies how to act if
  120. an error is encountered while reading the image. If
  121. <i>stopOnError</i> is non-zero, then an error will terminate
  122. the operation; otherwise <i>TIFFRGBAImageGet</i> will
  123. continue processing data until all the possible data in the
  124. image have been requested.</p>
  125. </td>
  126. </table>
  127. <a name="ALTERNATE RASTER FORMATS"></a>
  128. <h2>ALTERNATE RASTER FORMATS</h2>
  129. <!-- INDENTATION -->
  130. <table width="100%" border=0 rules="none" frame="void"
  131. cols="2" cellspacing="0" cellpadding="0">
  132. <tr valign="top" align="left">
  133. <td width="8%"></td>
  134. <td width="91%">
  135. <p>To use the core support for reading and processing
  136. <small>TIFF</small> images, but write the resulting raster
  137. data in a different format one need only override the
  138. &lsquo;&lsquo;<i>put methods</i>&rsquo;&rsquo; used to store
  139. raster data. These methods are are defined in the
  140. <i>TIFFRGBAImage</i> structure and initially setup by
  141. <i>TIFFRGBAImageBegin</i> to point to routines that pack
  142. raster data in the default <small>ABGR</small> pixel format.
  143. Two different routines are used according to the physical
  144. organization of the image data in the file:
  145. <i>PlanarConfiguration</i>=1 (packed samples), and
  146. <i>PlanarConfiguration</i>=2 (separated samples). Note that
  147. this mechanism can be used to transform the data before
  148. storing it in the raster. For example one can convert data
  149. to colormap indices for display on a colormap display.</p>
  150. </td>
  151. </table>
  152. <a name="SIMULTANEOUS RASTER STORE AND DISPLAY"></a>
  153. <h2>SIMULTANEOUS RASTER STORE AND DISPLAY</h2>
  154. <!-- INDENTATION -->
  155. <table width="100%" border=0 rules="none" frame="void"
  156. cols="2" cellspacing="0" cellpadding="0">
  157. <tr valign="top" align="left">
  158. <td width="8%"></td>
  159. <td width="91%">
  160. <p>It is simple to display an image as it is being read into
  161. memory by overriding the put methods as described above for
  162. supporting alternate raster formats. Simply keep a reference
  163. to the default put methods setup by
  164. <i>TIFFRGBAImageBegin</i> and then invoke them before or
  165. after each display operation. For example, the
  166. <i>tiffgt</i>(1) utility uses the following put method to
  167. update the display as the raster is being filled:</p>
  168. <!-- INDENTATION -->
  169. <pre>static void
  170. putContigAndDraw(TIFFRGBAImage* img, uint32_t* raster,
  171. uint32_t x, uint32_t y, uint32_t w, uint32_t h,
  172. int32_t fromskew, int32_t toskew,
  173. unsigned char* cp)
  174. {
  175. (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp);
  176. if (x+w == width) {
  177. w = width;
  178. if (img-&gt;orientation == ORIENTATION_TOPLEFT)
  179. lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w);
  180. else
  181. lrectwrite(0, y, w-1, y+h-1, raster);
  182. }
  183. }
  184. </pre>
  185. <!-- INDENTATION -->
  186. <p>(the original routine provided by the library is saved in
  187. the variable <i>putContig</i>.)</p>
  188. </td>
  189. </table>
  190. <a name="SUPPORTING ADDITIONAL TIFF FORMATS"></a>
  191. <h2>SUPPORTING ADDITIONAL TIFF FORMATS</h2>
  192. <!-- INDENTATION -->
  193. <table width="100%" border=0 rules="none" frame="void"
  194. cols="2" cellspacing="0" cellpadding="0">
  195. <tr valign="top" align="left">
  196. <td width="8%"></td>
  197. <td width="91%">
  198. <p>The <i>TIFFRGBAImage</i> routines support the most
  199. commonly encountered flavors of <small>TIFF.</small> It is
  200. possible to extend this support by overriding the
  201. &lsquo;&lsquo;<i>get method</i>&rsquo;&rsquo; invoked by
  202. <i>TIFFRGBAImageGet</i> to read <small>TIFF</small> image
  203. data. Details of doing this are a bit involved, it is best
  204. to make a copy of an existing get method and modify it to
  205. suit the needs of an application.</p>
  206. </td>
  207. </table>
  208. <a name="NOTES"></a>
  209. <h2>NOTES</h2>
  210. <!-- INDENTATION -->
  211. <table width="100%" border=0 rules="none" frame="void"
  212. cols="2" cellspacing="0" cellpadding="0">
  213. <tr valign="top" align="left">
  214. <td width="8%"></td>
  215. <td width="91%">
  216. <p>Samples must be either 1, 2, 4, 8, or 16 bits.
  217. Colorimetric samples/pixel must be either 1, 3, or 4 (i.e.
  218. <i>SamplesPerPixel</i> minus <i>ExtraSamples</i>).</p>
  219. <!-- INDENTATION -->
  220. <p>Palette image colormaps that appear to be incorrectly
  221. written as 8-bit values are automatically scaled to
  222. 16-bits.</p>
  223. </td>
  224. </table>
  225. <a name="RETURN VALUES"></a>
  226. <h2>RETURN VALUES</h2>
  227. <!-- INDENTATION -->
  228. <table width="100%" border=0 rules="none" frame="void"
  229. cols="2" cellspacing="0" cellpadding="0">
  230. <tr valign="top" align="left">
  231. <td width="8%"></td>
  232. <td width="91%">
  233. <p>All routines return 1 if the operation was successful.
  234. Otherwise, 0 is returned if an error was encountered and
  235. <i>stopOnError</i> is zero.</p>
  236. </td>
  237. </table>
  238. <a name="DIAGNOSTICS"></a>
  239. <h2>DIAGNOSTICS</h2>
  240. <!-- INDENTATION -->
  241. <table width="100%" border=0 rules="none" frame="void"
  242. cols="2" cellspacing="0" cellpadding="0">
  243. <tr valign="top" align="left">
  244. <td width="8%"></td>
  245. <td width="91%">
  246. <p>All error messages are directed to the
  247. <i>TIFFError</i>(3TIFF) routine.</p>
  248. <!-- INDENTATION -->
  249. <p><b>Sorry, can not handle %d-bit pictures</b>. The image
  250. had <i>BitsPerSample</i> other than 1, 2, 4, 8, or 16.</p>
  251. <!-- INDENTATION -->
  252. <p><b>Sorry, can not handle %d-channel images</b>. The image
  253. had <i>SamplesPerPixel</i> other than 1, 3, or 4.</p>
  254. <!-- INDENTATION -->
  255. <p><b>Missing needed &quot;PhotometricInterpretation&quot;
  256. tag</b>. The image did not have a tag that describes how to
  257. display the data.</p>
  258. <!-- INDENTATION -->
  259. <p><b>No &quot;PhotometricInterpretation&quot; tag, assuming
  260. RGB</b>. The image was missing a tag that describes how to
  261. display it, but because it has 3 or 4 samples/pixel, it is
  262. assumed to be <small>RGB.</small></p>
  263. <!-- INDENTATION -->
  264. <p><b>No &quot;PhotometricInterpretation&quot; tag, assuming
  265. min-is-black</b>. The image was missing a tag that describes
  266. how to display it, but because it has 1 sample/pixel, it is
  267. assumed to be a grayscale or bilevel image.</p>
  268. <!-- INDENTATION -->
  269. <p><b>No space for photometric conversion table</b>. There
  270. was insufficient memory for a table used to convert image
  271. samples to 8-bit <small>RGB.</small></p>
  272. <!-- INDENTATION -->
  273. <p><b>Missing required &quot;Colormap&quot; tag</b>. A
  274. Palette image did not have a required <i>Colormap</i>
  275. tag.</p>
  276. <!-- INDENTATION -->
  277. <p><b>No space for tile buffer</b>. There was insufficient
  278. memory to allocate an i/o buffer.</p>
  279. <!-- INDENTATION -->
  280. <p><b>No space for strip buffer</b>. There was insufficient
  281. memory to allocate an i/o buffer.</p>
  282. <!-- INDENTATION -->
  283. <p><b>Can not handle format</b>. The image has a format
  284. (combination of <i>BitsPerSample</i>,
  285. <i>SamplesPerPixel</i>, and
  286. <i>PhotometricInterpretation</i>) that can not be
  287. handled.</p>
  288. <!-- INDENTATION -->
  289. <p><b>No space for B&amp;W mapping table</b>. There was
  290. insufficient memory to allocate a table used to map
  291. grayscale data to <small>RGB.</small></p>
  292. <!-- INDENTATION -->
  293. <p><b>No space for Palette mapping table</b>. There was
  294. insufficient memory to allocate a table used to map data to
  295. 8-bit <small>RGB.</small></p>
  296. </td>
  297. </table>
  298. <a name="SEE ALSO"></a>
  299. <h2>SEE ALSO</h2>
  300. <!-- INDENTATION -->
  301. <table width="100%" border=0 rules="none" frame="void"
  302. cols="2" cellspacing="0" cellpadding="0">
  303. <tr valign="top" align="left">
  304. <td width="8%"></td>
  305. <td width="91%">
  306. <p><b>TIFFOpen</b>(3TIFF), <b>TIFFReadRGBAImage</b>(3TIFF),
  307. <b>TIFFReadRGBAImageOriented</b>(3TIFF),
  308. <b>TIFFReadRGBAStrip</b>(3TIFF),
  309. <b>TIFFReadRGBATile</b>(3TIFF), <b>libtiff</b>(3TIFF)</p>
  310. <!-- INDENTATION -->
  311. <p>Libtiff library home page:
  312. <b>http://www.simplesystems.org/libtiff/</b></p>
  313. </td>
  314. </table>
  315. <hr>
  316. </body>
  317. </html>