mi32/tiffio.h

Go to the documentation of this file.
00001 /**
00002  * \file tiffio.h <mi32/tiffio.h>
00003  * \brief  TIFF I/O Library Definitions.
00004  *
00005  * \if NODOC
00006  * $Log: tiffio.h_v $
00007  * Revision 1.21  2003/12/16 13:17:24  mju
00008  * Remove 'dollar'-header line so divergence comparison succeeds.
00009  *
00010  * Revision 1.20  2003/12/16 13:11:50  mju
00011  * Put stdincls back so library builds again.
00012  *
00013  * Revision 1.19  2003/12/08 18:16:58  scowan
00014  * Removed std incls.
00015  *
00016  * Revision 1.18  2003/09/15 22:06:25  dwilliss
00017  * Fixed errors introduced during Doxygen cleanup
00018  *
00019  * Revision 1.17  2003/09/15 13:49:56  fileserver!dwilliss
00020  * Doxygen
00021  *
00022  * \endif
00023  */
00024 
00025 /*
00026  * Copyright (c) 1988-1996 Sam Leffler
00027  * Copyright (c) 1991-1996 Silicon Graphics, Inc.
00028  *
00029  * Permission to use, copy, modify, distribute, and sell this software and 
00030  * its documentation for any purpose is hereby granted without fee, provided
00031  * that (i) the above copyright notices and this permission notice appear in
00032  * all copies of the software and related documentation, and (ii) the names of
00033  * Sam Leffler and Silicon Graphics may not be used in any advertising or
00034  * publicity relating to the software without the specific, prior written
00035  * permission of Sam Leffler and Silicon Graphics.
00036  * 
00037  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
00038  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
00039  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
00040  * 
00041  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
00042  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
00043  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00044  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
00045  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
00046  * OF THIS SOFTWARE.
00047  *
00048  */
00049 
00050 #ifndef INC_MI32_TIFFIO_H
00051 #define  INC_MI32_TIFFIO_H
00052 
00053 #ifndef  INC_STDIO_H
00054    #include <stdio.h>
00055    #define  INC_STDIO_H
00056 #endif
00057 
00058 #ifndef  INC_STDARG_H
00059    #include <stdarg.h>
00060    #define  INC_STDARG_H
00061 #endif
00062 
00063 #ifndef  INC_MI32_STDINCLS_H
00064    #include <mi32/stdincls.h>
00065 #endif
00066 
00067 #ifndef  INC_MI32_TIFF_H
00068    #include <mi32/tiff.h>
00069 #endif
00070 
00071 //!:Associate with "TIFF Functions"
00072 //!\addtogroup TIFF TIFF Functions
00073 //!@{
00074 
00075 /*
00076  * TIFF I/O Library Definitions.
00077  */
00078 /*
00079  * This define can be used in code that requires
00080  * compilation-related definitions specific to a
00081  * version or versions of the library.  Runtime
00082  * version checking should be done based on the
00083  * string returned by TIFFGetVersion.
00084  */
00085 #define  TIFFLIB_VERSION   19960307 //!<  March 7, 1996 
00086 
00087 /*
00088  * TIFF is defined as an incomplete type to hide the
00089  * library's internal data structures from clients.
00090  */
00091 typedef  struct tiff TIFF;
00092 
00093 /*
00094  * The following typedefs define the intrinsic size of
00095  * data types used in the *exported* interfaces.  These
00096  * definitions depend on the proper definition of types
00097  * in tiff.h.  Note also that the varargs interface used
00098  * pass tag types and values uses the types defined in
00099  * tiff.h directly.
00100  *
00101  * NB: ttag_t is unsigned int and not unsigned short because
00102  *     ANSI C requires that the type before the ellipsis be a
00103  *     promoted type (i.e. one of int, unsigned int, pointer,
00104  *     or double) and because we defined pseudo-tags that are
00105  *     outside the range of legal Aldus-assigned tags.
00106  * NB: tsize_t is int32 and not uint32 because some functions
00107  *     return -1.
00108  * NB: toff_t is not off_t for many reasons; TIFFs max out at
00109  *     32-bit file offsets being the most important
00110  */
00111 typedef  uint32 ttag_t;    //!<  directory tag 
00112 typedef  uint16 tdir_t;    //!<  directory index 
00113 typedef  uint16 tsample_t; //!<  sample number 
00114 typedef  uint32 tstrip_t;  //!<  strip number 
00115 typedef uint32 ttile_t;    //!<  tile number 
00116 typedef  int32 tsize_t;    //!<  i/o size in bytes 
00117 typedef  void* thandle_t;  //!<  client data handle 
00118 typedef  void* tdata_t;    //!<  image data ref 
00119 typedef  int32 toff_t;     //!<  file offset 
00120 
00121 #ifndef NULL
00122 #define  NULL  0
00123 #endif
00124 
00125 /*
00126  * Flags to pass to TIFFPrintDirectory to control
00127  * printing of data structures that are potentially
00128  * very large.   Bit-or these flags to enable printing
00129  * multiple items.
00130  */
00131 #define  TIFFPRINT_NONE    0x0      //!<  no extra info 
00132 #define  TIFFPRINT_STRIPS  0x1      //!<  strips/tiles info 
00133 #define  TIFFPRINT_CURVES  0x2      //!<  color/gray response curves 
00134 #define  TIFFPRINT_COLORMAP   0x4      //!<  colormap 
00135 #define  TIFFPRINT_JPEGQTABLES   0x100    //!<  JPEG Q matrices 
00136 #define  TIFFPRINT_JPEGACTABLES  0x200    //!<  JPEG AC tables 
00137 #define  TIFFPRINT_JPEGDCTABLES  0x200    //!<  JPEG DC tables 
00138 
00139 /*
00140  * RGBA-style image support.
00141  */
00142 typedef  unsigned char TIFFRGBValue;      //!<  8-bit samples 
00143 typedef struct _TIFFRGBAImage TIFFRGBAImage;
00144 /*
00145  * The image reading and conversion routines invoke
00146  * ``put routines'' to copy/image/whatever tiles of
00147  * raw image data.  A default set of routines are 
00148  * provided to convert/copy raw image data to 8-bit
00149  * packed ABGR format rasters.  Applications can supply
00150  * alternate routines that unpack the data into a
00151  * different format or, for example, unpack the data
00152  * and draw the unpacked raster on the display.
00153  */
00154 typedef void (*tileContigRoutine)
00155     (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
00156    unsigned char*);
00157 typedef void (*tileSeparateRoutine)
00158     (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
00159    unsigned char*, unsigned char*, unsigned char*, unsigned char*);
00160 /*
00161  * RGBA-reader state.
00162  */
00163 /*\if NODOC*/
00164 typedef struct {           /* YCbCr->RGB support */
00165    TIFFRGBValue* clamptab;       //!<  range clamping table 
00166    int*  Cr_r_tab;
00167    int*  Cb_b_tab;
00168    int32*   Cr_g_tab;
00169    int32*   Cb_g_tab;
00170    float coeffs[3];        //!<  cached for repeated use 
00171 } TIFFYCbCrToRGB;
00172 
00173 struct _TIFFRGBAImage {
00174    TIFF* tif;           //!<  image handle 
00175    int   stoponerr;        //!<  stop on read error 
00176    int   isContig;         //!<  data is packed/separate 
00177    int   alpha;            //!<  type of alpha data present 
00178    uint32   width;            //!<  image width 
00179    uint32   height;           //!<  image height 
00180    uint16   bitspersample;       //!<  image bits/sample 
00181    uint16   samplesperpixel;     //!<  image samples/pixel 
00182    uint16   orientation;         //!<  image orientation 
00183    uint16   photometric;         //!<  image photometric interp 
00184    uint16*  redcmap;       //!<  colormap pallete 
00185    uint16*  greencmap;
00186    uint16*  bluecmap;
00187                   /* get image data routine */
00188    int   (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
00189    union {
00190        void (*any)(TIFFRGBAImage*);
00191        tileContigRoutine   contig;
00192        tileSeparateRoutine separate;
00193    } put;               //!<  put decoded strip/tile 
00194    TIFFRGBValue* Map;         //!<  sample mapping array 
00195    uint32** BWmap;            //!<  black&white map 
00196    uint32** PALmap;        //!<  palette image map 
00197    TIFFYCbCrToRGB* ycbcr;        //!<  YCbCr conversion state 
00198 };
00199 /*\endif*/
00200 
00201 /*
00202  * Macros for extracting components from the
00203  * packed ABGR form returned by TIFFReadRGBAImage.
00204  */
00205 #define  TIFFGetR(abgr) ((abgr) & 0xff)
00206 #define  TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
00207 #define  TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
00208 #define  TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
00209 
00210 /*
00211  * A CODEC is a software package that implements decoding,
00212  * encoding, or decoding+encoding of a compression algorithm.
00213  * The library provides a collection of builtin codecs.
00214  * More codecs may be registered through calls to the library
00215  * and/or the builtin implementations may be overridden.
00216  */
00217 typedef  int (*TIFFInitMethod)(TIFF*, int);
00218 typedef struct {
00219    char*    name;
00220    uint16      scheme;
00221    TIFFInitMethod init;
00222 } TIFFCodec;
00223 
00224 #ifdef TIFFDLL
00225    #define LIBEXPORT MI_DLLEXPORT
00226 #else
00227    #define LIBEXPORT MI_DLLIMPORT
00228 #endif
00229 
00230 #if defined(__cplusplus)
00231 extern "C" {
00232 #endif
00233 typedef  void (*TIFFErrorHandler)(const UNICODE*, const char*, va_list);
00234 typedef  tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);
00235 typedef  toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
00236 typedef  int (*TIFFCloseProc)(thandle_t);
00237 typedef  toff_t (*TIFFSizeProc)(thandle_t);
00238 typedef  int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);
00239 typedef  void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);
00240 typedef  void (*TIFFExtendProc)(TIFF*); 
00241 
00242 
00243 extern      const char*       TIFFGetVersion(void);
00244 
00245 extern      const TIFFCodec*  TIFFFindCODEC(uint16);
00246 extern      TIFFCodec*        TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
00247 extern      void              TIFFUnRegisterCODEC(TIFFCodec*);
00248 
00249 extern      tdata_t           _TIFFmalloc(tsize_t);
00250 extern      tdata_t           _TIFFrealloc(tdata_t, tsize_t);
00251 extern      void              _TIFFmemset(tdata_t, int, tsize_t);
00252 extern      void              _TIFFmemcpy(tdata_t, const tdata_t, tsize_t);
00253 extern      int               _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t);
00254 extern      void              _TIFFfree(tdata_t);
00255 
00256 extern      void              TIFFClose(TIFF*);
00257 extern      int               TIFFFlush(TIFF*);
00258 extern      int               TIFFFlushData(TIFF*);
00259 LIBEXPORT   int               TIFFGetField(TIFF*, ttag_t, ...);
00260 extern      int               TIFFVGetField(TIFF*, ttag_t, va_list);
00261 LIBEXPORT   int               TIFFGetFieldDefaulted(TIFF*, ttag_t, ...);
00262 extern      int               TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list);
00263 LIBEXPORT   int               TIFFReadDirectory(TIFF*);
00264 extern      tsize_t           TIFFScanlineSize(TIFF*);
00265 extern      tsize_t           TIFFRasterScanlineSize(TIFF*);
00266 LIBEXPORT   tsize_t           TIFFStripSize(TIFF*);
00267 extern      tsize_t           TIFFVStripSize(TIFF*, uint32);
00268 extern      tsize_t           TIFFTileRowSize(TIFF*);
00269 LIBEXPORT   tsize_t           TIFFTileSize(TIFF*);
00270 extern      tsize_t           TIFFVTileSize(TIFF*, uint32);
00271 extern      uint32            TIFFDefaultStripSize(TIFF*, uint32);
00272 extern      void              TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
00273 extern      int               TIFFGetMode(TIFF*);
00274 LIBEXPORT   int               TIFFIsTiled(TIFF*);
00275 extern      int               TIFFIsByteSwapped(TIFF*);
00276 extern      int               TIFFIsUpSampled(TIFF*);
00277 extern      int               TIFFIsMSB2LSB(TIFF*);
00278 extern      uint32            TIFFCurrentRow(TIFF*);
00279 LIBEXPORT   tdir_t            TIFFCurrentDirectory(TIFF*);
00280 extern      uint32            TIFFCurrentDirOffset(TIFF*);
00281 extern      tstrip_t          TIFFCurrentStrip(TIFF*);
00282 extern      ttile_t           TIFFCurrentTile(TIFF*);
00283 extern      int               TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t);
00284 extern      int               TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t);
00285 LIBEXPORT   int               TIFFLastDirectory(TIFF*);
00286 LIBEXPORT   int               TIFFSetDirectory(TIFF*, tdir_t);
00287 extern      int               TIFFSetSubDirectory(TIFF*, uint32);
00288 extern      int               TIFFUnlinkDirectory(TIFF*, tdir_t);
00289 LIBEXPORT   int               TIFFSetField(TIFF*, ttag_t, ...);
00290 extern      int               TIFFVSetField(TIFF*, ttag_t, va_list);
00291 LIBEXPORT   int               TIFFWriteDirectory(TIFF *);
00292 #if defined(__cplusplus)
00293 extern      void              TIFFPrintDirectory(TIFF*, FILE*, long = 0);
00294 extern      int               TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
00295 extern      int               TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
00296 extern      int               TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
00297 #else
00298 extern      void              TIFFPrintDirectory(TIFF*, FILE*, long);
00299 LIBEXPORT   int               TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t);
00300 LIBEXPORT   int               TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t);
00301 extern      int               TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
00302 #endif
00303 extern      int               TIFFRGBAImageOK(TIFF*, char [1024]);
00304 extern      int               TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
00305 extern      int               TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
00306 extern      void              TIFFRGBAImageEnd(TIFFRGBAImage*);
00307 extern      TIFF*             TIFFOpen(const UNICODE*, const char*);
00308 extern      TIFF*             TIFFClientOpen(const UNICODE*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc);
00309 extern      UNICODE*          TIFFFileName(TIFF*);
00310 extern      void              TIFFError(const char*, const char*, ...);
00311 extern      void              TIFFErrorUC(const UNICODE*, const char*, ...);
00312 extern      void              TIFFWarning(const char*, const char*, ...);
00313 extern      void              TIFFWarningUC(const UNICODE*, const char*, ...);
00314 LIBEXPORT   TIFFErrorHandler  TIFFSetErrorHandler(TIFFErrorHandler);
00315 LIBEXPORT   TIFFErrorHandler  TIFFSetWarningHandler(TIFFErrorHandler);
00316 extern      TIFFExtendProc    TIFFSetTagExtender(TIFFExtendProc);
00317 LIBEXPORT   ttile_t           TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t);
00318 extern      int               TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t);
00319 extern      ttile_t           TIFFNumberOfTiles(TIFF*);
00320 LIBEXPORT   tsize_t           TIFFReadTile(TIFF*, tdata_t, uint32, uint32, uint32, tsample_t);
00321 LIBEXPORT   tsize_t           TIFFWriteTile(TIFF*, tdata_t, uint32, uint32, uint32, tsample_t);
00322 extern      tstrip_t          TIFFComputeStrip(TIFF*, uint32, tsample_t);
00323 extern      tstrip_t          TIFFNumberOfStrips(TIFF*);
00324 LIBEXPORT   tsize_t           TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
00325 extern      tsize_t           TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
00326 LIBEXPORT   tsize_t           TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
00327 extern      tsize_t           TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
00328 LIBEXPORT   tsize_t           TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
00329 extern      tsize_t           TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
00330 LIBEXPORT   tsize_t           TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
00331 extern      tsize_t           TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
00332 extern      void              TIFFSetWriteOffset(TIFF*, toff_t);
00333 extern      void              TIFFSwabShort(uint16*);
00334 extern      void              TIFFSwabLong(uint32*);
00335 extern      void              TIFFSwabDouble(double*);
00336 extern      void              TIFFSwabArrayOfShort(uint16*, unsigned long);
00337 extern      void              TIFFSwabArrayOfLong(uint32*, unsigned long);
00338 extern      void              TIFFSwabArrayOfDouble(double*, unsigned long);
00339 extern      void              TIFFReverseBits(unsigned char *, unsigned long);
00340 extern      const unsigned char* TIFFGetBitRevTable(int);
00341 #if defined(__cplusplus)
00342 }
00343 #endif
00344 
00345 #undef LIBEXPORT
00346 
00347 //!@}
00348 
00349 #endif //!<  INC_MI32_TIFFIO_H 

Generated on Thu Aug 12 06:19:10 2004 for TNTsdk by doxygen 1.3.4-20031026