roentgen b75cab
roentgen b75cab
roentgen b75cab
<title></title>
roentgen b75cab
Modifying The TIFF Library
roentgen b75cab
roentgen b75cab
roentgen b75cab
 
roentgen b75cab
<font face="Arial, Helvetica, Sans"></font>
roentgen b75cab

roentgen b75cab
roentgen b75cab
Modifying The TIFF Library
roentgen b75cab
roentgen b75cab
roentgen b75cab
roentgen b75cab

roentgen b75cab
This chapter provides information about the internal structure of
roentgen b75cab
the library, how to control the configuration when building it, and
roentgen b75cab
how to add new support to the library.
roentgen b75cab
The following sections are found in this chapter:
roentgen b75cab
roentgen b75cab
    roentgen b75cab
  • Library Configuration
  • roentgen b75cab
  • General Portability Comments
  • roentgen b75cab
  • Types and Portability
  • roentgen b75cab
  • Adding New Tags
  • roentgen b75cab
  • Adding New Builtin Codecs
  • roentgen b75cab
  • Adding New Codec-private Tags
  • roentgen b75cab
  • Other Comments
  • roentgen b75cab
    roentgen b75cab
    roentgen b75cab
    roentgen b75cab


    Library Configuration

    roentgen b75cab
    roentgen b75cab
    Information on compiling the library is given
    roentgen b75cab
    elsewhere in this documentation.
    roentgen b75cab
    This section describes the low-level mechanisms used to control
    roentgen b75cab
    the optional parts of the library that are configured at build
    roentgen b75cab
    time.   Control is based on
    roentgen b75cab
    a collection of C defines that are specified either on the compiler
    roentgen b75cab
    command line or in a configuration file such as <tt>port.h</tt>
    roentgen b75cab
    (as generated by the <tt>configure</tt> script for UNIX systems)
    roentgen b75cab
    or tiffconf.h.
    roentgen b75cab
    roentgen b75cab

    roentgen b75cab
    Configuration defines are split into three areas:
    roentgen b75cab
      roentgen b75cab
    • those that control which compression schemes are
    • roentgen b75cab
          configured as part of the builtin codecs,
      roentgen b75cab
    • those that control support for groups of tags that
    • roentgen b75cab
          are considered optional, and
      roentgen b75cab
    • those that control operating system or machine-specific support.
    • roentgen b75cab
      roentgen b75cab
      roentgen b75cab

      roentgen b75cab
      If the define <tt>COMPRESSION_SUPPORT</tt> is not defined
      roentgen b75cab
      then a default set of compression schemes is automatically
      roentgen b75cab
      configured:
      roentgen b75cab
        roentgen b75cab
      • CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4, and 32771),
      • roentgen b75cab
      • the Macintosh PackBits algorithm (compression 32773),
      • roentgen b75cab
      • a 4-bit run-length encoding scheme from ThunderScan (compression 32809),
      • roentgen b75cab
      • a 2-bit encoding scheme used by NeXT (compression 32766), and
      • roentgen b75cab
      • two experimental schemes intended for images with high dynamic range
      • roentgen b75cab
        (compression 34676 and 34677).
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        roentgen b75cab
        To override the default compression behaviour define
        roentgen b75cab
        <tt>COMPRESSION_SUPPORT</tt> and then one or more additional defines
        roentgen b75cab
        to enable configuration of the appropriate codecs (see the table
        roentgen b75cab
        below); e.g.
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        #define	COMPRESSION_SUPPORT
        roentgen b75cab
        #define	CCITT_SUPPORT
        roentgen b75cab
        #define	PACKBITS_SUPPORT
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        Several other compression schemes are configured separately from
        roentgen b75cab
        the default set because they depend on ancillary software
        roentgen b75cab
        packages that are not distributed with <tt>libtiff</tt>.
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        Support for JPEG compression is controlled by <tt>JPEG_SUPPORT</tt>.
        roentgen b75cab
        The JPEG codec that comes with <tt>libtiff</tt> is designed for
        roentgen b75cab
        use with release 5 or later of the Independent JPEG Group's freely
        roentgen b75cab
        available software distribution.
        roentgen b75cab
        This software can be retrieved from the directory
        roentgen b75cab
        ftp.uu.net:/graphics/jpeg/.
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        NOTE: 
        roentgen b75cab
        Enabling JPEG support automatically enables support for
        roentgen b75cab
        the TIFF 6.0 colorimetry and YCbCr-related tags.
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        Experimental support for the deflate algorithm is controlled by
        roentgen b75cab
        <tt>DEFLATE_SUPPORT</tt>.
        roentgen b75cab
        The deflate codec that comes with <tt>libtiff</tt> is designed
        roentgen b75cab
        for use with version 0.99 or later of the freely available
        roentgen b75cab
        <tt>libz</tt> library written by Jean-loup Gailly and Mark Adler.
        roentgen b75cab
        The data format used by this library is described
        roentgen b75cab
        in the files
        roentgen b75cab
        zlib-3.1.doc,
        roentgen b75cab
        and
        roentgen b75cab
        deflate-1.1.doc,
        roentgen b75cab
        available in the directory
        roentgen b75cab
        ftp.uu.net:/pub/archiving/zip/doc.
        roentgen b75cab
        The library can be retried from the directory
        roentgen b75cab
        ftp.uu.net:/pub/archiving/zip/zlib/
        roentgen b75cab
        (or try quest.jpl.nasa.gov:/beta/zlib/).
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        NOTE: 
        roentgen b75cab
        The deflate algorithm is experimental.  Do not expect
        roentgen b75cab
        to exchange files using this compression scheme;
        roentgen b75cab
        it is included only because the similar, and more common,
        roentgen b75cab
        LZW algorithm is claimed to be governed by licensing restrictions.
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        By default tiffconf.h defines
        roentgen b75cab
        <tt>COLORIMETRY_SUPPORT</tt>, 
        roentgen b75cab
        <tt>YCBCR_SUPPORT</tt>,
        roentgen b75cab
        and 
        roentgen b75cab
        <tt>CMYK_SUPPORT</tt>.
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        DefineDescription
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>CCITT_SUPPORT</tt>
        roentgen b75cab
        CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4,
        roentgen b75cab
            and 32771)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>PACKBITS_SUPPORT</tt>
        roentgen b75cab
        Macintosh PackBits algorithm (compression 32773)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>LZW_SUPPORT</tt>
        roentgen b75cab
        Lempel-Ziv & Welch (LZW) algorithm (compression 5)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>THUNDER_SUPPORT</tt>
        roentgen b75cab
        4-bit
        roentgen b75cab
        run-length encoding scheme from ThunderScan (compression 32809)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>NEXT_SUPPORT</tt>
        roentgen b75cab
        2-bit encoding scheme used by NeXT (compression 32766)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>OJPEG_SUPPORT</tt>
        roentgen b75cab
        obsolete JPEG scheme defined in the 6.0 spec (compression 6)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>JPEG_SUPPORT</tt>
        roentgen b75cab
        current JPEG scheme defined in TTN2 (compression 7)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>ZIP_SUPPORT</tt>
        roentgen b75cab
        experimental Deflate scheme (compression 32946)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>PIXARLOG_SUPPORT</tt>
        roentgen b75cab
        Pixar's compression scheme for high-resolution color images (compression 32909)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>SGILOG_SUPPORT</tt>
        roentgen b75cab
        SGI's compression scheme for high-resolution color images (compression 34676 and 34677)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>COLORIMETRY_SUPPORT</tt>
        roentgen b75cab
        support for the TIFF 6.0 colorimetry tags
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>YCBCR_SUPPORT</tt>
        roentgen b75cab
        support for the TIFF 6.0 YCbCr-related tags
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>CMYK_SUPPORT</tt>
        roentgen b75cab
        support for the TIFF 6.0 CMYK-related tags
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>ICC_SUPPORT</tt>
        roentgen b75cab
        support for the ICC Profile tag; see
        roentgen b75cab
        The ICC Profile Format Specification,
        roentgen b75cab
        Annex B.3 "Embedding ICC Profiles in TIFF Files";
        roentgen b75cab
        available at
        roentgen b75cab
        http://www.color.org
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab


        General Portability Comments

        roentgen b75cab
        roentgen b75cab
        This software is developed on Silicon Graphics UNIX
        roentgen b75cab
        systems (big-endian, MIPS CPU, 32-bit ints,
        roentgen b75cab
        IEEE floating point). 
        roentgen b75cab
        The <tt>configure</tt> shell script generates the appropriate
        roentgen b75cab
        include files and make files for UNIX systems.
        roentgen b75cab
        Makefiles exist for non-UNIX platforms that the
        roentgen b75cab
        code runs on -- this work has mostly been done by other people.
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        In general, the code is guaranteed to work only on SGI machines.
        roentgen b75cab
        In practice it is highly portable to any 32-bit or 64-bit system and much
        roentgen b75cab
        work has been done to insure portability to 16-bit systems.
        roentgen b75cab
        If you encounter portability problems please return fixes so
        roentgen b75cab
        that future distributions can be improved.
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        The software is written to assume an ANSI C compilation environment.
        roentgen b75cab
        If your compiler does not support ANSI function prototypes, <tt>const</tt>,
        roentgen b75cab
        and <tt><stdarg.h></tt> then you will have to make modifications to the
        roentgen b75cab
        software.  In the past I have tried to support compilers without <tt>const</tt>
        roentgen b75cab
        and systems without <tt><stdarg.h></tt>, but I am
        roentgen b75cab
        no longer interested in these
        roentgen b75cab
        antiquated environments.  With the general availability of
        roentgen b75cab
        the freely available GCC compiler, I
        roentgen b75cab
        see no reason to incorporate modifications to the software for these
        roentgen b75cab
        purposes.
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        An effort has been made to isolate as many of the
        roentgen b75cab
        operating system-dependencies
        roentgen b75cab
        as possible in two files: tiffcomp.h and
        roentgen b75cab
        libtiff/tif_<os>.c.  The latter file contains
        roentgen b75cab
        operating system-specific routines to do I/O and I/O-related operations.
        roentgen b75cab
        The UNIX (tif_unix.c),
        roentgen b75cab
        Macintosh (tif_apple.c),
        roentgen b75cab
        and VMS (tif_vms.c)
        roentgen b75cab
        code has had the most use;
        roentgen b75cab
        the MS/DOS support (tif_msdos.c) assumes
        roentgen b75cab
        some level of UNIX system call emulation (i.e.
        roentgen b75cab
        <tt>open</tt>,
        roentgen b75cab
        <tt>read</tt>,
        roentgen b75cab
        <tt>write</tt>,
        roentgen b75cab
        <tt>fstat</tt>,
        roentgen b75cab
        <tt>malloc</tt>,
        roentgen b75cab
        <tt>free</tt>).
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        Native CPU byte order is determined on the fly by
        roentgen b75cab
        the library and does not need to be specified.
        roentgen b75cab
        The <tt>HOST_FILLORDER</tt> and <tt>HOST_BIGENDIAN</tt>
        roentgen b75cab
        definitions are not currently used, but may be employed by
        roentgen b75cab
        codecs for optimization purposes.
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        The following defines control general portability:
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>BSDTYPES</tt>
        roentgen b75cab
        Define this if your system does NOT define the
        roentgen b75cab
        		usual BSD typedefs: <tt>u_char</tt>,
        roentgen b75cab
        		<tt>u_short</tt>, <tt>u_int</tt>, <tt>u_long</tt>.
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>HAVE_IEEEFP</tt>
        roentgen b75cab
        Define this as 0 or 1 according to the floating point
        roentgen b75cab
        		format suported by the machine.  If your machine does
        roentgen b75cab
        		not support IEEE floating point then you will need to
        roentgen b75cab
        		add support to tif_machdep.c to convert between the
        roentgen b75cab
        		native format and IEEE format.
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>HAVE_MMAP</tt>
        roentgen b75cab
        Define this if there is mmap-style support for
        roentgen b75cab
        mapping files into memory (used only to read data).
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>HOST_FILLORDER</tt>
        roentgen b75cab
        Define the native CPU bit order: one of <tt>FILLORDER_MSB2LSB</tt>
        roentgen b75cab
         or <tt>FILLORDER_LSB2MSB</tt>
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        <tt>HOST_BIGENDIAN</tt>
        roentgen b75cab
        Define the native CPU byte order: 1 if big-endian (Motorola)
        roentgen b75cab
         or 0 if little-endian (Intel); this may be used
        roentgen b75cab
         in codecs to optimize code
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        On UNIX systems <tt>HAVE_MMAP</tt> is defined through the running of
        roentgen b75cab
        the <tt>configure</tt> script; otherwise support for memory-mapped
        roentgen b75cab
        files is disabled.
        roentgen b75cab
        Note that tiffcomp.h defines <tt>HAVE_IEEEFP</tt> to be
        roentgen b75cab
        1 (<tt>BSDTYPES</tt> is not defined).
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab


        Types and Portability

        roentgen b75cab
        roentgen b75cab
        The software makes extensive use of C typedefs to promote portability.
        roentgen b75cab
        Two sets of typedefs are used, one for communication with clients
        roentgen b75cab
        of the library and one for internal data structures and parsing of the
        roentgen b75cab
        TIFF format.  There are interactions between these two to be careful
        roentgen b75cab
        of, but for the most part you should be able to deal with portability
        roentgen b75cab
        purely by fiddling with the following machine-dependent typedefs:
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        uint8
        roentgen b75cab
        8-bit unsigned integer
        roentgen b75cab
        tiff.h
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        int8
        roentgen b75cab
        8-bit signed integer
        roentgen b75cab
        tiff.h
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        uint16
        roentgen b75cab
        16-bit unsigned integer
        roentgen b75cab
        tiff.h
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        int16
        roentgen b75cab
        16-bit signed integer
        roentgen b75cab
        tiff.h
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        uint32
        roentgen b75cab
        32-bit unsigned integer
        roentgen b75cab
        tiff.h
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        int32
        roentgen b75cab
        32-bit signed integer
        roentgen b75cab
        tiff.h
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        dblparam_t
        roentgen b75cab
        promoted type for floats
        roentgen b75cab
        tiffcomp.h
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        (to clarify <tt>dblparam_t</tt>, it is the type that float parameters are
        roentgen b75cab
        promoted to when passed by value in a function call.)
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        The following typedefs are used throughout the library and interfaces
        roentgen b75cab
        to refer to certain objects whose size is dependent on the TIFF image
        roentgen b75cab
        structure:
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        typedef unsigned int ttag_t;	directory tag
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        typedef uint16 tdir_t;		directory index
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        typedef uint16 tsample_t;	sample number
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        typedef uint32 tstrip_t;	strip number
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        typedef uint32 ttile_t;		tile number
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        typedef int32 tsize_t;		i/o size in bytes
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        typedef void* tdata_t;		image data ref
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        typedef void* thandle_t;	client data handle
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        typedef int32 toff_t;		file offset (should be off_t)
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        typedef unsigned char* tidata_t; internal image data
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab

        roentgen b75cab
        Note that <tt>tstrip_t</tt>, <tt>ttile_t</tt>, and <tt>tsize_t</tt>
        roentgen b75cab
        are constrained to be
        roentgen b75cab
        no more than 32-bit quantities by 32-bit fields they are stored
        roentgen b75cab
        in in the TIFF image.  Likewise <tt>tsample_t</tt> is limited by the 16-bit
        roentgen b75cab
        field used to store the <tt>SamplesPerPixel</tt> tag.  <tt>tdir_t</tt>
        roentgen b75cab
        constrains
        roentgen b75cab
        the maximum number of IFDs that may appear in an image and may
        roentgen b75cab
        be an arbitrary size (without penalty).  <tt>ttag_t</tt> must be either
        roentgen b75cab
        <tt>int</tt>, <tt>unsigned int</tt>, pointer, or <tt>double</tt>
        roentgen b75cab
        because the library uses a varargs
        roentgen b75cab
        interface and ANSI C restricts the type of the parameter before an
        roentgen b75cab
        ellipsis to be a promoted type.  <tt>toff_t</tt> is defined as
        roentgen b75cab
        <tt>int32</tt> because
        roentgen b75cab
        TIFF file offsets are (unsigned) 32-bit quantities.  A signed
        roentgen b75cab
        value is used because some interfaces return -1 on error (sigh).
        roentgen b75cab
        Finally, note that <tt>tidata_t</tt> is used internally to the library to
        roentgen b75cab
        manipulate internal data.  User-specified data references are
        roentgen b75cab
        passed as opaque handles and only cast at the lowest layers where
        roentgen b75cab
        their type is presumed.
        roentgen b75cab
        roentgen b75cab
        roentgen b75cab


        General Comments

        roentgen b75cab
        roentgen b75cab
        The library is designed to hide as much of the details of TIFF from
        roentgen b75cab
        applications as
        roentgen b75cab
        possible.  In particular, TIFF directories are read in their entirety
        roentgen b75cab
        into an internal format.  Only the tags known by the library are
        roentgen b75cab
        available to a user and certain tag data may be maintained that a user
        roentgen b75cab
        does not care about (e.g. transfer function tables).
        roentgen b75cab
        roentgen b75cab


        Adding New Builtin Codecs

        roentgen b75cab
        roentgen b75cab
        To add builtin support for a new compression algorithm, you can either
        roentgen b75cab
        use the "tag-extension" trick to override the handling of the
        roentgen b75cab
        TIFF Compression tag (see Adding New Tags), 
        roentgen b75cab
        or do the following to add support directly to the core library:
        roentgen b75cab
        roentgen b75cab
          roentgen b75cab
        1. Define the tag value in tiff.h.
        2. roentgen b75cab
        3. Edit the file tif_codec.c to add an entry to the
        4. roentgen b75cab
             _TIFFBuiltinCODECS array (see how other algorithms are handled).
          roentgen b75cab
        5. Add the appropriate function prototype declaration to
        6. roentgen b75cab
             tiffiop.h (close to the bottom).
          roentgen b75cab
        7. Create a file with the compression scheme code, by convention files
        8. roentgen b75cab
             are named tif_*.c (except perhaps on some systems where the
          roentgen b75cab
             tif_ prefix pushes some filenames over 14 chars.
          roentgen b75cab
        9. Edit Makefile.in (and any other Makefiles)
        10. roentgen b75cab
             to include the new source file.
          roentgen b75cab
          roentgen b75cab
          roentgen b75cab

          roentgen b75cab
          A codec, say <tt>foo</tt>, can have many different entry points:
          roentgen b75cab
          roentgen b75cab
          roentgen b75cab
          TIFFInitfoo(tif, scheme)/* initialize scheme and setup entry points in tif */
          roentgen b75cab
          fooSetupDecode(tif)	/* called once per IFD after tags has been frozen */
          roentgen b75cab
          fooPreDecode(tif, sample)/* called once per strip/tile, after data is read,
          roentgen b75cab
          			    but before the first row is decoded */
          roentgen b75cab
          fooDecode*(tif, bp, cc, sample)/* decode cc bytes of data into the buffer */
          roentgen b75cab
              fooDecodeRow(...)	/* called to decode a single scanline */
          roentgen b75cab
              fooDecodeStrip(...)	/* called to decode an entire strip */
          roentgen b75cab
              fooDecodeTile(...)	/* called to decode an entire tile */
          roentgen b75cab
          fooSetupEncode(tif)	/* called once per IFD after tags has been frozen */
          roentgen b75cab
          fooPreEncode(tif, sample)/* called once per strip/tile, before the first row in
          roentgen b75cab
          			    a strip/tile is encoded */
          roentgen b75cab
          fooEncode*(tif, bp, cc, sample)/* encode cc bytes of user data (bp) */
          roentgen b75cab
              fooEncodeRow(...)	/* called to decode a single scanline */
          roentgen b75cab
              fooEncodeStrip(...)	/* called to decode an entire strip */
          roentgen b75cab
              fooEncodeTile(...)	/* called to decode an entire tile */
          roentgen b75cab
          fooPostEncode(tif)	/* called once per strip/tile, just before data is written */
          roentgen b75cab
          fooSeek(tif, row)	/* seek forwards row scanlines from the beginning
          roentgen b75cab
          			   of a strip (row will always be >0 and <rows/strip */
          roentgen b75cab
          fooCleanup(tif)		/* called when compression scheme is replaced by user */
          roentgen b75cab
          roentgen b75cab
          roentgen b75cab

          roentgen b75cab
          Note that the encoding and decoding variants are only needed when
          roentgen b75cab
          a compression algorithm is dependent on the structure of the data.
          roentgen b75cab
          For example, Group 3 2D encoding and decoding maintains a reference
          roentgen b75cab
          scanline.  The sample parameter identifies which sample is to be
          roentgen b75cab
          encoded or decoded if the image is organized with <tt>PlanarConfig</tt>=2
          roentgen b75cab
          (separate planes).  This is important for algorithms such as JPEG.
          roentgen b75cab
          If <tt>PlanarConfig</tt>=1 (interleaved), then sample will always be 0.
          roentgen b75cab
          roentgen b75cab


          Other Comments

          roentgen b75cab
          roentgen b75cab
          The library handles most I/O buffering.  There are two data buffers
          roentgen b75cab
          when decoding data: a raw data buffer that holds all the data in a
          roentgen b75cab
          strip, and a user-supplied scanline buffer that compression schemes
          roentgen b75cab
          place decoded data into.  When encoding data the data in the
          roentgen b75cab
          user-supplied scanline buffer is encoded into the raw data buffer (from
          roentgen b75cab
          where it is written).  Decoding routines should never have to explicitly
          roentgen b75cab
          read data -- a full strip/tile's worth of raw data is read and scanlines
          roentgen b75cab
          never cross strip boundaries.  Encoding routines must be cognizant of
          roentgen b75cab
          the raw data buffer size and call <tt>TIFFFlushData1()</tt> when necessary.
          roentgen b75cab
          Note that any pending data is automatically flushed when a new strip/tile is
          roentgen b75cab
          started, so there's no need do that in the tif_postencode routine (if
          roentgen b75cab
          one exists).  Bit order is automatically handled by the library when
          roentgen b75cab
          a raw strip or tile is filled.  If the decoded samples are interpreted
          roentgen b75cab
          by the decoding routine before they are passed back to the user, then
          roentgen b75cab
          the decoding logic must handle byte-swapping by overriding the
          roentgen b75cab
          <tt>tif_postdecode</tt>
          roentgen b75cab
          routine (set it to <tt>TIFFNoPostDecode</tt>) and doing the required work
          roentgen b75cab
          internally.  For an example of doing this look at the horizontal
          roentgen b75cab
          differencing code in the routines in tif_predict.c.
          roentgen b75cab
          roentgen b75cab

          roentgen b75cab
          The variables <tt>tif_rawcc</tt>, <tt>tif_rawdata</tt>, and
          roentgen b75cab
          <tt>tif_rawcp</tt> in a <tt>TIFF</tt> structure
          roentgen b75cab
          are associated with the raw data buffer.  <tt>tif_rawcc</tt> must be non-zero
          roentgen b75cab
          for the library to automatically flush data.  The variable
          roentgen b75cab
          <tt>tif_scanlinesize</tt> is the size a user's scanline buffer should be.  The
          roentgen b75cab
          variable <tt>tif_tilesize</tt> is the size of a tile for tiled images.  This
          roentgen b75cab
          should not normally be used by compression routines, except where it
          roentgen b75cab
          relates to the compression algorithm.  That is, the <tt>cc</tt> parameter to the
          roentgen b75cab
          <tt>tif_decode*</tt> and <tt>tif_encode*</tt>
          roentgen b75cab
          routines should be used in terminating
          roentgen b75cab
          decompression/compression.  This ensures these routines can be used,
          roentgen b75cab
          for example, to decode/encode entire strips of data.
          roentgen b75cab
          roentgen b75cab

          roentgen b75cab
          In general, if you have a new compression algorithm to add, work from
          roentgen b75cab
          the code for an existing routine.  In particular,
          roentgen b75cab
          tif_dumpmode.c
          roentgen b75cab
          has the trivial code for the "nil" compression scheme,
          roentgen b75cab
          tif_packbits.c is a
          roentgen b75cab
          simple byte-oriented scheme that has to watch out for buffer
          roentgen b75cab
          boundaries, and tif_lzw.c has the LZW scheme that has the most
          roentgen b75cab
          complexity -- it tracks the buffer boundary at a bit level.
          roentgen b75cab
          Of course, using a private compression scheme (or private tags) limits
          roentgen b75cab
          the portability of your TIFF files.
          roentgen b75cab
          roentgen b75cab

          roentgen b75cab

          roentgen b75cab
          roentgen b75cab
          Last updated: $Date: 2004/09/10 14:47:31 $
          roentgen b75cab
          roentgen b75cab
          roentgen b75cab
          roentgen b75cab