internals.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <TITLE>
  5. Modifying The TIFF Library
  6. </TITLE>
  7. <style type="text/css">
  8. body {
  9. font-family: Arial, Helvetica, Sans;
  10. }
  11. </style>
  12. </HEAD>
  13. <BODY>
  14. <H1>
  15. <IMG SRC="images/dave.gif" WIDTH=107 HEIGHT=148 BORDER=2 ALIGN=left HSPACE=6 ALT="dave">
  16. Modifying The TIFF Library
  17. </H1>
  18. <P>
  19. This chapter provides information about the internal structure of
  20. the library, how to control the configuration when building it, and
  21. how to add new support to the library.
  22. The following sections are found in this chapter:
  23. <UL>
  24. <LI><A HREF="#Config">Library Configuration</A>
  25. <LI><A HREF="#Portability">General Portability Comments</A>
  26. <LI><A HREF="#Types">Types and Portability</A>
  27. <LI><A HREF="addingtags.html">Adding New Tags</A>
  28. <LI><A HREF="#AddingCODECS">Adding New Builtin Codecs</A>
  29. <LI><A HREF="addingtags.html#AddingCODECTags">Adding New Codec-private Tags</A>
  30. <LI><A HREF="#Other">Other Comments</A>
  31. </UL>
  32. <HR WIDTH="65%" ALIGN=right>
  33. <H3 id="Config">Library Configuration</H3>
  34. <P>
  35. Information on compiling the library is given
  36. <A HREF=build.html>elsewhere in this documentation</A>.
  37. This section describes the low-level mechanisms used to control
  38. the optional parts of the library that are configured at build
  39. time. Control is based on
  40. a collection of C defines that are specified either on the compiler
  41. command line or in a configuration file such as <TT>port.h</TT>
  42. (as generated by the <TT>configure</TT> script for UNIX systems)
  43. or <B>tiffconf.h</B>.
  44. <P>
  45. Configuration defines are split into three areas:
  46. <UL>
  47. <LI>those that control which compression schemes are
  48. configured as part of the builtin codecs,
  49. <LI>those that control support for groups of tags that
  50. are considered optional, and
  51. <LI>those that control operating system or machine-specific support.
  52. </UL>
  53. <P>
  54. If the define <TT>COMPRESSION_SUPPORT</TT> is <STRONG>not defined</STRONG>
  55. then a default set of compression schemes is automatically
  56. configured:
  57. <UL>
  58. <LI>CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4, and 32771),
  59. <LI>the Macintosh PackBits algorithm (compression 32773),
  60. <LI>a 4-bit run-length encoding scheme from ThunderScan (compression 32809),
  61. <LI>a 2-bit encoding scheme used by NeXT (compression 32766), and
  62. <LI>two experimental schemes intended for images with high dynamic range
  63. (compression 34676 and 34677).
  64. </UL>
  65. <P>
  66. To override the default compression behaviour define
  67. <TT>COMPRESSION_SUPPORT</TT> and then one or more additional defines
  68. to enable configuration of the appropriate codecs (see the table
  69. below); e.g.
  70. <PRE style="margin-left: 3em;">
  71. #define COMPRESSION_SUPPORT
  72. #define CCITT_SUPPORT
  73. #define PACKBITS_SUPPORT
  74. </PRE>
  75. Several other compression schemes are configured separately from
  76. the default set because they depend on ancillary software
  77. packages that are not distributed with <TT>libtiff</TT>.
  78. <P>
  79. Support for JPEG compression is controlled by <TT>JPEG_SUPPORT</TT>.
  80. The JPEG codec that comes with <TT>libtiff</TT> is designed for
  81. use with release 5 or later of the Independent JPEG Group's freely
  82. available software distribution.
  83. This software can be retrieved from the directory
  84. <A HREF="ftp://ftp.uu.net/graphics/jpeg">ftp.uu.net:/graphics/jpeg/</A>.
  85. <P>
  86. <IMG SRC="images/info.gif" ALT="NOTE: " ALIGN=left HSPACE=8>
  87. <EM>Enabling JPEG support automatically enables support for
  88. the TIFF 6.0 colorimetry and YCbCr-related tags.</EM>
  89. <P>
  90. Experimental support for the deflate algorithm is controlled by
  91. <TT>DEFLATE_SUPPORT</TT>.
  92. The deflate codec that comes with <TT>libtiff</TT> is designed
  93. for use with version 0.99 or later of the freely available
  94. <TT>libz</TT> library written by Jean-loup Gailly and Mark Adler.
  95. The data format used by this library is described
  96. in the files
  97. <A HREF="ftp://ftp.uu.net/pub/archiving/zip/doc/zlib-3.1.doc">zlib-3.1.doc</A>,
  98. and
  99. <A HREF="ftp://ftp.uu.net/pub/archiving/zip/doc/deflate-1.1.doc">deflate-1.1.doc</A>,
  100. available in the directory
  101. <A HREF="ftp://ftp.uu.net/pub/archiving/zip/doc">ftp.uu.net:/pub/archiving/zip/doc</A>.
  102. The library can be retried from the directory
  103. <A HREF="ftp://ftp.uu.net/pub/archiving/zip/zlib/">ftp.uu.net:/pub/archiving/zip/zlib/</A>
  104. (or try <A HREF="ftp://quest.jpl.nasa.gov/beta/zlib/">quest.jpl.nasa.gov:/beta/zlib/</A>).
  105. <P>
  106. <IMG SRC="images/warning.gif" ALT="NOTE: " ALIGN=left HSPACE=8 VSPACE=6>
  107. <EM>The deflate algorithm is experimental. Do not expect
  108. to exchange files using this compression scheme;
  109. it is included only because the similar, and more common,
  110. LZW algorithm is claimed to be governed by licensing restrictions.</EM>
  111. <P>
  112. By default <B>tiffconf.h</B> defines
  113. <TT>COLORIMETRY_SUPPORT</TT>,
  114. <TT>YCBCR_SUPPORT</TT>,
  115. and
  116. <TT>CMYK_SUPPORT</TT>.
  117. <P>
  118. <TABLE BORDER CELLPADDING=3>
  119. <TR><TH ALIGN=left>Define</TH><TH ALIGN=left>Description</TH></TR>
  120. <TR>
  121. <TD VALIGN=top><TT>CCITT_SUPPORT</TT></TD>
  122. <TD>CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4,
  123. and 32771)</TD>
  124. </TR>
  125. <TR>
  126. <TD VALIGN=top><TT>PACKBITS_SUPPORT</TT></TD>
  127. <TD>Macintosh PackBits algorithm (compression 32773)</TD>
  128. </TR>
  129. <TR>
  130. <TD VALIGN=top><TT>LZW_SUPPORT</TT></TD>
  131. <TD>Lempel-Ziv & Welch (LZW) algorithm (compression 5)</TD>
  132. </TR>
  133. <TR>
  134. <TD VALIGN=top><TT>THUNDER_SUPPORT</TT></TD>
  135. <TD>4-bit
  136. run-length encoding scheme from ThunderScan (compression 32809)</TD>
  137. </TR>
  138. <TR>
  139. <TD VALIGN=top><TT>NEXT_SUPPORT</TT></TD>
  140. <TD>2-bit encoding scheme used by NeXT (compression 32766)</TD>
  141. </TR>
  142. <TR>
  143. <TD VALIGN=top><TT>OJPEG_SUPPORT</TT></TD>
  144. <TD>obsolete JPEG scheme defined in the 6.0 spec (compression 6)</TD>
  145. </TR>
  146. <TR>
  147. <TD VALIGN=top><TT>JPEG_SUPPORT</TT></TD>
  148. <TD>current JPEG scheme defined in TTN2 (compression 7)</TD>
  149. </TR>
  150. <TR>
  151. <TD VALIGN=top><TT>ZIP_SUPPORT</TT></TD>
  152. <TD>experimental Deflate scheme (compression 32946)</TD>
  153. </TR>
  154. <TR>
  155. <TD VALIGN=top><TT>PIXARLOG_SUPPORT</TT></TD>
  156. <TD>Pixar's compression scheme for high-resolution color images (compression 32909)</TD>
  157. </TR>
  158. <TR>
  159. <TD VALIGN=top><TT>SGILOG_SUPPORT</TT></TD>
  160. <TD>SGI's compression scheme for high-resolution color images (compression 34676 and 34677)</TD>
  161. </TR>
  162. <TR>
  163. <TD VALIGN=top><TT>COLORIMETRY_SUPPORT</TT></TD>
  164. <TD>support for the TIFF 6.0 colorimetry tags</TD>
  165. </TR>
  166. <TR>
  167. <TD VALIGN=top><TT>YCBCR_SUPPORT</TT></TD>
  168. <TD>support for the TIFF 6.0 YCbCr-related tags</TD>
  169. </TR>
  170. <TR>
  171. <TD VALIGN=top><TT>CMYK_SUPPORT</TT></TD>
  172. <TD>support for the TIFF 6.0 CMYK-related tags</TD>
  173. </TR>
  174. <TR>
  175. <TD VALIGN=top><TT>ICC_SUPPORT</TT></TD>
  176. <TD>support for the ICC Profile tag; see
  177. <I>The ICC Profile Format Specification</I>,
  178. Annex B.3 "Embedding ICC Profiles in TIFF Files";
  179. available at
  180. <A HREF="http://www.color.org">http://www.color.org</A>
  181. </TD>
  182. </TR>
  183. </TABLE>
  184. <HR WIDTH="65%" ALIGN=right>
  185. <H3 id="Portability">General Portability Comments</H3>
  186. <P>
  187. This software is developed on Silicon Graphics UNIX
  188. systems (big-endian, MIPS CPU, 32-bit ints,
  189. IEEE floating point).
  190. The <TT>configure</TT> shell script generates the appropriate
  191. include files and make files for UNIX systems.
  192. Makefiles exist for non-UNIX platforms that the
  193. code runs on -- this work has mostly been done by other people.
  194. <P>
  195. In general, the code is guaranteed to work only on SGI machines.
  196. In practice it is highly portable to any 32-bit or 64-bit system and much
  197. work has been done to insure portability to 16-bit systems.
  198. If you encounter portability problems please return fixes so
  199. that future distributions can be improved.
  200. <P>
  201. The software is written to assume an ANSI C compilation environment.
  202. If your compiler does not support ANSI function prototypes, <TT>const</TT>,
  203. and <TT>&lt;stdarg.h&gt;</TT> then you will have to make modifications to the
  204. software. In the past I have tried to support compilers without <TT>const</TT>
  205. and systems without <TT>&lt;stdarg.h&gt;</TT>, but I am
  206. <EM>no longer interested in these
  207. antiquated environments</EM>. With the general availability of
  208. the freely available GCC compiler, I
  209. see no reason to incorporate modifications to the software for these
  210. purposes.
  211. <P>
  212. An effort has been made to isolate as many of the
  213. operating system-dependencies
  214. as possible in two files: <B>tiffcomp.h</B> and
  215. <B>libtiff/tif_&lt;os&gt;.c</B>. The latter file contains
  216. operating system-specific routines to do I/O and I/O-related operations.
  217. The UNIX (<B>tif_unix.c</B>) code has had the most use.
  218. <P>
  219. Native CPU byte order is determined on the fly by
  220. the library and does not need to be specified.
  221. The <TT>HOST_FILLORDER</TT> and <TT>HOST_BIGENDIAN</TT>
  222. definitions are not currently used, but may be employed by
  223. codecs for optimization purposes.
  224. <P>
  225. The following defines control general portability:
  226. <P>
  227. <TABLE BORDER CELLPADDING=3 WIDTH="100%">
  228. <TR>
  229. <TD VALIGN=top><TT>BSDTYPES</TT></TD>
  230. <TD>Define this if your system does NOT define the
  231. usual BSD typedefs: <TT>u_char</TT>,
  232. <TT>u_short</TT>, <TT>u_int</TT>, <TT>u_long</TT>.</TD>
  233. </TR>
  234. <TR>
  235. <TD VALIGN=top><TT>HAVE_IEEEFP</TT></TD>
  236. <TD>Define this as 0 or 1 according to the floating point
  237. format supported by the machine. If your machine does
  238. not support IEEE floating point then you will need to
  239. add support to tif_machdep.c to convert between the
  240. native format and IEEE format.</TD>
  241. </TR>
  242. <TR>
  243. <TD VALIGN=top><TT>HAVE_MMAP</TT></TD>
  244. <TD>Define this if there is <I>mmap-style</I> support for
  245. mapping files into memory (used only to read data).</TD>
  246. </TR>
  247. <TR>
  248. <TD VALIGN=top><TT>HOST_FILLORDER</TT></TD>
  249. <TD>Define the native CPU bit order: one of <TT>FILLORDER_MSB2LSB</TT>
  250. or <TT>FILLORDER_LSB2MSB</TT></TD>
  251. </TR>
  252. <TR>
  253. <TD VALIGN=top><TT>HOST_BIGENDIAN</TT></TD>
  254. <TD>Define the native CPU byte order: 1 if big-endian (Motorola)
  255. or 0 if little-endian (Intel); this may be used
  256. in codecs to optimize code</TD>
  257. </TR>
  258. </TABLE>
  259. <P>
  260. On UNIX systems <TT>HAVE_MMAP</TT> is defined through the running of
  261. the <TT>configure</TT> script; otherwise support for memory-mapped
  262. files is disabled.
  263. Note that <B>tiffcomp.h</B> defines <TT>HAVE_IEEEFP</TT> to be
  264. 1 (<TT>BSDTYPES</TT> is not defined).
  265. <HR WIDTH="65%" ALIGN=right>
  266. <H3 id="Types">Types and Portability</H3>
  267. <P>
  268. The software makes extensive use of C typedefs to promote portability.
  269. Two sets of typedefs are used, one for communication with clients
  270. of the library and one for internal data structures and parsing of the
  271. TIFF format. There are interactions between these two to be careful
  272. of, but for the most part you should be able to deal with portability
  273. purely by fiddling with the following machine-dependent typedefs:
  274. <P>
  275. <TABLE BORDER CELLPADDING=3 WIDTH="100%">
  276. <TR>
  277. <TD>uint8_t</TD>
  278. <TD>8-bit unsigned integer</TD>
  279. <TD>tiff.h</TD>
  280. </TR>
  281. <TR>
  282. <TD>int8_t</TD>
  283. <TD>8-bit signed integer</TD>
  284. <TD>tiff.h</TD>
  285. </TR>
  286. <TR>
  287. <TD>uint16_t</TD>
  288. <TD>16-bit unsigned integer</TD>
  289. <TD>tiff.h</TD>
  290. </TR>
  291. <TR>
  292. <TD>int16_t</TD>
  293. <TD>16-bit signed integer</TD>
  294. <TD>tiff.h</TD>
  295. </TR>
  296. <TR>
  297. <TD>uint32_t</TD>
  298. <TD>32-bit unsigned integer</TD>
  299. <TD>tiff.h</TD>
  300. </TR>
  301. <TR>
  302. <TD>int32_t</TD>
  303. <TD>32-bit signed integer</TD>
  304. <TD>tiff.h</TD>
  305. </TR>
  306. <TR>
  307. <TD>dblparam_t</TD>
  308. <TD>promoted type for floats</TD>
  309. <TD>tiffcomp.h</TD>
  310. </TR>
  311. </TABLE>
  312. <P>
  313. (to clarify <TT>dblparam_t</TT>, it is the type that float parameters are
  314. promoted to when passed by value in a function call.)
  315. <P>
  316. The following typedefs are used throughout the library and interfaces
  317. to refer to certain objects whose size is dependent on the TIFF image
  318. structure:
  319. <P>
  320. <TABLE BORDER CELLPADDING=3 WIDTH="100%">
  321. <TR>
  322. <TD WIDTH="25%">typedef unsigned int ttag_t;</TD> <TD>directory tag</TD>
  323. </TR>
  324. <TR>
  325. <TD>typedef uint16_t tdir_t;</TD> <TD>directory index</TD>
  326. </TR>
  327. <TR>
  328. <TD>typedef uint16_t tsample_t;</TD> <TD>sample number</TD>
  329. </TR>
  330. <TR>
  331. <TD>typedef uint32_t tstrip_t;</TD> <TD>strip number</TD>
  332. </TR>
  333. <TR>
  334. <TD>typedef uint32_t ttile_t;</TD> <TD>tile number</TD>
  335. </TR>
  336. <TR>
  337. <TD>typedef int32_t tsize_t;</TD> <TD>i/o size in bytes</TD>
  338. </TR>
  339. <TR>
  340. <TD>typedef void* tdata_t;</TD> <TD>image data ref</TD>
  341. </TR>
  342. <TR>
  343. <TD>typedef void* thandle_t;</TD> <TD>client data handle</TD>
  344. </TR>
  345. <TR>
  346. <TD>typedef int32_t toff_t;</TD> <TD>file offset (should be off_t)</TD>
  347. </TR>
  348. <TR>
  349. <TD>typedef unsigned char* tidata_t;</TD> <TD>internal image data</TD>
  350. </TR>
  351. </TABLE>
  352. <P>
  353. Note that <TT>tstrip_t</TT>, <TT>ttile_t</TT>, and <TT>tsize_t</TT>
  354. are constrained to be
  355. no more than 32-bit quantities by 32-bit fields they are stored
  356. in in the TIFF image. Likewise <TT>tsample_t</TT> is limited by the 16-bit
  357. field used to store the <TT>SamplesPerPixel</TT> tag. <TT>tdir_t</TT>
  358. constrains
  359. the maximum number of IFDs that may appear in an image and may
  360. be an arbitrary size (without penalty). <TT>ttag_t</TT> must be either
  361. <TT>int</TT>, <TT>unsigned int</TT>, pointer, or <TT>double</TT>
  362. because the library uses a varargs
  363. interface and ANSI C restricts the type of the parameter before an
  364. ellipsis to be a promoted type. <TT>toff_t</TT> is defined as
  365. <TT>int32_t</TT> because
  366. TIFF file offsets are (unsigned) 32-bit quantities. A signed
  367. value is used because some interfaces return -1 on error (sigh).
  368. Finally, note that <TT>tidata_t</TT> is used internally to the library to
  369. manipulate internal data. User-specified data references are
  370. passed as opaque handles and only cast at the lowest layers where
  371. their type is presumed.
  372. <HR WIDTH="65%" ALIGN=right>
  373. <H3>General Comments</H3>
  374. <P>
  375. The library is designed to hide as much of the details of TIFF from
  376. applications as
  377. possible. In particular, TIFF directories are read in their entirety
  378. into an internal format. Only the tags known by the library are
  379. available to a user and certain tag data may be maintained that a user
  380. does not care about (e.g. transfer function tables).
  381. <HR WIDTH="65%" ALIGN=right>
  382. <H3 id="AddingCODECS">Adding New Builtin Codecs</H3>
  383. <P>
  384. To add builtin support for a new compression algorithm, you can either
  385. use the "tag-extension" trick to override the handling of the
  386. TIFF Compression tag (see <A HREF=addingtags.html>Adding New Tags</A>),
  387. or do the following to add support directly to the core library:
  388. <OL>
  389. <LI>Define the tag value in <B>tiff.h</B>.
  390. <LI>Edit the file <B>tif_codec.c</B> to add an entry to the
  391. _TIFFBuiltinCODECS array (see how other algorithms are handled).
  392. <LI>Add the appropriate function prototype declaration to
  393. <B>tiffiop.h</B> (close to the bottom).
  394. <LI>Create a file with the compression scheme code, by convention files
  395. are named <B>tif_*.c</B> (except perhaps on some systems where the
  396. tif_ prefix pushes some filenames over 14 chars.
  397. <LI>Edit <B>Makefile.in</B> (and any other Makefiles)
  398. to include the new source file.
  399. </OL>
  400. <P>
  401. A codec, say <TT>foo</TT>, can have many different entry points:
  402. <PRE>
  403. TIFFInitfoo(tif, scheme)/* initialize scheme and setup entry points in tif */
  404. fooSetupDecode(tif) /* called once per IFD after tags has been frozen */
  405. fooPreDecode(tif, sample)/* called once per strip/tile, after data is read,
  406. but before the first row is decoded */
  407. fooDecode*(tif, bp, cc, sample)/* decode cc bytes of data into the buffer */
  408. fooDecodeRow(...) /* called to decode a single scanline */
  409. fooDecodeStrip(...) /* called to decode an entire strip */
  410. fooDecodeTile(...) /* called to decode an entire tile */
  411. fooSetupEncode(tif) /* called once per IFD after tags has been frozen */
  412. fooPreEncode(tif, sample)/* called once per strip/tile, before the first row in
  413. a strip/tile is encoded */
  414. fooEncode*(tif, bp, cc, sample)/* encode cc bytes of user data (bp) */
  415. fooEncodeRow(...) /* called to decode a single scanline */
  416. fooEncodeStrip(...) /* called to decode an entire strip */
  417. fooEncodeTile(...) /* called to decode an entire tile */
  418. fooPostEncode(tif) /* called once per strip/tile, just before data is written */
  419. fooSeek(tif, row) /* seek forwards row scanlines from the beginning
  420. of a strip (row will always be &gt;0 and &lt;rows/strip */
  421. fooCleanup(tif) /* called when compression scheme is replaced by user */
  422. </PRE>
  423. <P>
  424. Note that the encoding and decoding variants are only needed when
  425. a compression algorithm is dependent on the structure of the data.
  426. For example, Group 3 2D encoding and decoding maintains a reference
  427. scanline. The sample parameter identifies which sample is to be
  428. encoded or decoded if the image is organized with <TT>PlanarConfig</TT>=2
  429. (separate planes). This is important for algorithms such as JPEG.
  430. If <TT>PlanarConfig</TT>=1 (interleaved), then sample will always be 0.
  431. <HR WIDTH="65%" ALIGN=right>
  432. <H3 id="Other">Other Comments</H3>
  433. <P>
  434. The library handles most I/O buffering. There are two data buffers
  435. when decoding data: a raw data buffer that holds all the data in a
  436. strip, and a user-supplied scanline buffer that compression schemes
  437. place decoded data into. When encoding data the data in the
  438. user-supplied scanline buffer is encoded into the raw data buffer (from
  439. where it is written). Decoding routines should never have to explicitly
  440. read data -- a full strip/tile's worth of raw data is read and scanlines
  441. never cross strip boundaries. Encoding routines must be cognizant of
  442. the raw data buffer size and call <TT>TIFFFlushData1()</TT> when necessary.
  443. Note that any pending data is automatically flushed when a new strip/tile is
  444. started, so there's no need do that in the tif_postencode routine (if
  445. one exists). Bit order is automatically handled by the library when
  446. a raw strip or tile is filled. If the decoded samples are interpreted
  447. by the decoding routine before they are passed back to the user, then
  448. the decoding logic must handle byte-swapping by overriding the
  449. <TT>tif_postdecode</TT>
  450. routine (set it to <TT>TIFFNoPostDecode</TT>) and doing the required work
  451. internally. For an example of doing this look at the horizontal
  452. differencing code in the routines in <B>tif_predict.c</B>.
  453. <P>
  454. The variables <TT>tif_rawcc</TT>, <TT>tif_rawdata</TT>, and
  455. <TT>tif_rawcp</TT> in a <TT>TIFF</TT> structure
  456. are associated with the raw data buffer. <TT>tif_rawcc</TT> must be non-zero
  457. for the library to automatically flush data. The variable
  458. <TT>tif_scanlinesize</TT> is the size a user's scanline buffer should be. The
  459. variable <TT>tif_tilesize</TT> is the size of a tile for tiled images. This
  460. should not normally be used by compression routines, except where it
  461. relates to the compression algorithm. That is, the <TT>cc</TT> parameter to the
  462. <TT>tif_decode*</TT> and <TT>tif_encode*</TT>
  463. routines should be used in terminating
  464. decompression/compression. This ensures these routines can be used,
  465. for example, to decode/encode entire strips of data.
  466. <P>
  467. In general, if you have a new compression algorithm to add, work from
  468. the code for an existing routine. In particular,
  469. <B>tif_dumpmode.c</B>
  470. has the trivial code for the "nil" compression scheme,
  471. <B>tif_packbits.c</B> is a
  472. simple byte-oriented scheme that has to watch out for buffer
  473. boundaries, and <B>tif_lzw.c</B> has the LZW scheme that has the most
  474. complexity -- it tracks the buffer boundary at a bit level.
  475. Of course, using a private compression scheme (or private tags) limits
  476. the portability of your TIFF files.
  477. <P>
  478. <HR>
  479. Last updated: $Date: 2016-09-25 20:05:44 $
  480. </BODY>
  481. </HTML>