home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activetcltk / ActiveTcl8.3.4.1-8.win32-ix86.exe / ActiveTcl8.3.4.1-win32-ix86 / include / tiffio.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-22  |  12.5 KB  |  328 lines

  1. /* $Header: /cvsroot/osrs/libtiff/libtiff/tiffio.h,v 1.5 2000/01/28 21:09:02 warmerda Exp $ */
  2.  
  3. /*
  4.  * Copyright (c) 1988-1997 Sam Leffler
  5.  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
  6.  *
  7.  * Permission to use, copy, modify, distribute, and sell this software and 
  8.  * its documentation for any purpose is hereby granted without fee, provided
  9.  * that (i) the above copyright notices and this permission notice appear in
  10.  * all copies of the software and related documentation, and (ii) the names of
  11.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  12.  * publicity relating to the software without the specific, prior written
  13.  * permission of Sam Leffler and Silicon Graphics.
  14.  * 
  15.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  16.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  17.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  18.  * 
  19.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  20.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  21.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  22.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  23.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  24.  * OF THIS SOFTWARE.
  25.  */
  26.  
  27. #ifndef _TIFFIO_
  28. #define    _TIFFIO_
  29.  
  30. /*
  31.  * TIFF I/O Library Definitions.
  32.  */
  33. #include "tiff.h"
  34.  
  35. /*
  36.  * This define can be used in code that requires
  37.  * compilation-related definitions specific to a
  38.  * version or versions of the library.  Runtime
  39.  * version checking should be done based on the
  40.  * string returned by TIFFGetVersion.
  41.  */
  42. #define    TIFFLIB_VERSION    19970127    /* January 27, 1997 */
  43.  
  44. /*
  45.  * TIFF is defined as an incomplete type to hide the
  46.  * library's internal data structures from clients.
  47.  */
  48. typedef    struct tiff TIFF;
  49.  
  50. /*
  51.  * The following typedefs define the intrinsic size of
  52.  * data types used in the *exported* interfaces.  These
  53.  * definitions depend on the proper definition of types
  54.  * in tiff.h.  Note also that the varargs interface used
  55.  * to pass tag types and values uses the types defined in
  56.  * tiff.h directly.
  57.  *
  58.  * NB: ttag_t is unsigned int and not unsigned short because
  59.  *     ANSI C requires that the type before the ellipsis be a
  60.  *     promoted type (i.e. one of int, unsigned int, pointer,
  61.  *     or double) and because we defined pseudo-tags that are
  62.  *     outside the range of legal Aldus-assigned tags.
  63.  * NB: tsize_t is int32 and not uint32 because some functions
  64.  *     return -1.
  65.  * NB: toff_t is not off_t for many reasons; TIFFs max out at
  66.  *     32-bit file offsets being the most important, and to ensure
  67.  *     that it is unsigned, rather than signed.
  68.  */
  69. typedef    uint32 ttag_t;        /* directory tag */
  70. typedef    uint16 tdir_t;        /* directory index */
  71. typedef    uint16 tsample_t;    /* sample number */
  72. typedef    uint32 tstrip_t;    /* strip number */
  73. typedef uint32 ttile_t;        /* tile number */
  74. typedef    int32 tsize_t;        /* i/o size in bytes */
  75. typedef    void* tdata_t;        /* image data ref */
  76. typedef    uint32 toff_t;        /* file offset */
  77.  
  78. #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
  79. #define __WIN32__
  80. #endif
  81. #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
  82. #include <windows.h>
  83. #ifdef __WIN32__
  84. DECLARE_HANDLE(thandle_t);    /* Win32 file handle */
  85. #else
  86. typedef    HFILE thandle_t;    /* client data handle */
  87. #endif
  88. #else
  89. typedef    void* thandle_t;    /* client data handle */
  90. #endif
  91.  
  92. #ifndef NULL
  93. #define    NULL    0
  94. #endif
  95.  
  96. /*
  97.  * Flags to pass to TIFFPrintDirectory to control
  98.  * printing of data structures that are potentially
  99.  * very large.   Bit-or these flags to enable printing
  100.  * multiple items.
  101.  */
  102. #define    TIFFPRINT_NONE        0x0        /* no extra info */
  103. #define    TIFFPRINT_STRIPS    0x1        /* strips/tiles info */
  104. #define    TIFFPRINT_CURVES    0x2        /* color/gray response curves */
  105. #define    TIFFPRINT_COLORMAP    0x4        /* colormap */
  106. #define    TIFFPRINT_JPEGQTABLES    0x100        /* JPEG Q matrices */
  107. #define    TIFFPRINT_JPEGACTABLES    0x200        /* JPEG AC tables */
  108. #define    TIFFPRINT_JPEGDCTABLES    0x200        /* JPEG DC tables */
  109.  
  110. /*
  111.  * RGBA-style image support.
  112.  */
  113. typedef    unsigned char TIFFRGBValue;        /* 8-bit samples */
  114. typedef struct _TIFFRGBAImage TIFFRGBAImage;
  115. /*
  116.  * The image reading and conversion routines invoke
  117.  * ``put routines'' to copy/image/whatever tiles of
  118.  * raw image data.  A default set of routines are 
  119.  * provided to convert/copy raw image data to 8-bit
  120.  * packed ABGR format rasters.  Applications can supply
  121.  * alternate routines that unpack the data into a
  122.  * different format or, for example, unpack the data
  123.  * and draw the unpacked raster on the display.
  124.  */
  125. typedef void (*tileContigRoutine)
  126.     (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
  127.     unsigned char*);
  128. typedef void (*tileSeparateRoutine)
  129.     (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
  130.     unsigned char*, unsigned char*, unsigned char*, unsigned char*);
  131. /*
  132.  * RGBA-reader state.
  133.  */
  134. typedef struct {                /* YCbCr->RGB support */
  135.     TIFFRGBValue* clamptab;            /* range clamping table */
  136.     int*    Cr_r_tab;
  137.     int*    Cb_b_tab;
  138.     int32*    Cr_g_tab;
  139.     int32*    Cb_g_tab;
  140.     float    coeffs[3];            /* cached for repeated use */
  141. } TIFFYCbCrToRGB;
  142.  
  143. struct _TIFFRGBAImage {
  144.     TIFF*    tif;                /* image handle */
  145.     int    stoponerr;            /* stop on read error */
  146.     int    isContig;            /* data is packed/separate */
  147.     int    alpha;                /* type of alpha data present */
  148.     uint32    width;                /* image width */
  149.     uint32    height;                /* image height */
  150.     uint16    bitspersample;            /* image bits/sample */
  151.     uint16    samplesperpixel;        /* image samples/pixel */
  152.     uint16    orientation;            /* image orientation */
  153.     uint16    photometric;            /* image photometric interp */
  154.     uint16*    redcmap;            /* colormap pallete */
  155.     uint16*    greencmap;
  156.     uint16*    bluecmap;
  157.                         /* get image data routine */
  158.     int    (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
  159.     union {
  160.         void (*any)(TIFFRGBAImage*);
  161.         tileContigRoutine    contig;
  162.         tileSeparateRoutine    separate;
  163.     } put;                    /* put decoded strip/tile */
  164.     TIFFRGBValue* Map;            /* sample mapping array */
  165.     uint32** BWmap;                /* black&white map */
  166.     uint32** PALmap;            /* palette image map */
  167.     TIFFYCbCrToRGB* ycbcr;            /* YCbCr conversion state */
  168.  
  169.         int    row_offset;
  170.         int     col_offset;
  171. };
  172.  
  173. /*
  174.  * Macros for extracting components from the
  175.  * packed ABGR form returned by TIFFReadRGBAImage.
  176.  */
  177. #define    TIFFGetR(abgr)    ((abgr) & 0xff)
  178. #define    TIFFGetG(abgr)    (((abgr) >> 8) & 0xff)
  179. #define    TIFFGetB(abgr)    (((abgr) >> 16) & 0xff)
  180. #define    TIFFGetA(abgr)    (((abgr) >> 24) & 0xff)
  181.  
  182. /*
  183.  * A CODEC is a software package that implements decoding,
  184.  * encoding, or decoding+encoding of a compression algorithm.
  185.  * The library provides a collection of builtin codecs.
  186.  * More codecs may be registered through calls to the library
  187.  * and/or the builtin implementations may be overridden.
  188.  */
  189. typedef    int (*TIFFInitMethod)(TIFF*, int);
  190. typedef struct {
  191.     char*        name;
  192.     uint16        scheme;
  193.     TIFFInitMethod    init;
  194. } TIFFCodec;
  195.  
  196. #include <stdio.h>
  197. #include <stdarg.h>
  198.  
  199. #if defined(__cplusplus)
  200. extern "C" {
  201. #endif
  202. typedef    void (*TIFFErrorHandler)(const char*, const char*, va_list);
  203. typedef    tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);
  204. typedef    toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
  205. typedef    int (*TIFFCloseProc)(thandle_t);
  206. typedef    toff_t (*TIFFSizeProc)(thandle_t);
  207. typedef    int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);
  208. typedef    void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);
  209. typedef    void (*TIFFExtendProc)(TIFF*); 
  210.  
  211. extern    const char* TIFFGetVersion(void);
  212.  
  213. extern    const TIFFCodec* TIFFFindCODEC(uint16);
  214. extern    TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
  215. extern    void TIFFUnRegisterCODEC(TIFFCodec*);
  216.  
  217. extern    tdata_t _TIFFmalloc(tsize_t);
  218. extern    tdata_t _TIFFrealloc(tdata_t, tsize_t);
  219. extern    void _TIFFmemset(tdata_t, int, tsize_t);
  220. extern    void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t);
  221. extern    int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t);
  222. extern    void _TIFFfree(tdata_t);
  223.  
  224. extern    void TIFFClose(TIFF*);
  225. extern    int TIFFFlush(TIFF*);
  226. extern    int TIFFFlushData(TIFF*);
  227. extern    int TIFFGetField(TIFF*, ttag_t, ...);
  228. extern    int TIFFVGetField(TIFF*, ttag_t, va_list);
  229. extern    int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...);
  230. extern    int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list);
  231. extern    int TIFFReadDirectory(TIFF*);
  232. extern    tsize_t TIFFScanlineSize(TIFF*);
  233. extern    tsize_t TIFFRasterScanlineSize(TIFF*);
  234. extern    tsize_t TIFFStripSize(TIFF*);
  235. extern    tsize_t TIFFVStripSize(TIFF*, uint32);
  236. extern    tsize_t TIFFTileRowSize(TIFF*);
  237. extern    tsize_t TIFFTileSize(TIFF*);
  238. extern    tsize_t TIFFVTileSize(TIFF*, uint32);
  239. extern    uint32 TIFFDefaultStripSize(TIFF*, uint32);
  240. extern    void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
  241. extern    int TIFFFileno(TIFF*);
  242. extern    int TIFFGetMode(TIFF*);
  243. extern    int TIFFIsTiled(TIFF*);
  244. extern    int TIFFIsByteSwapped(TIFF*);
  245. extern    int TIFFIsUpSampled(TIFF*);
  246. extern    int TIFFIsMSB2LSB(TIFF*);
  247. extern    uint32 TIFFCurrentRow(TIFF*);
  248. extern    tdir_t TIFFCurrentDirectory(TIFF*);
  249. extern    tdir_t TIFFNumberOfDirectories(TIFF*);
  250. extern    uint32 TIFFCurrentDirOffset(TIFF*);
  251. extern    tstrip_t TIFFCurrentStrip(TIFF*);
  252. extern    ttile_t TIFFCurrentTile(TIFF*);
  253. extern    int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t);
  254. extern    int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t);
  255. extern  int TIFFWriteCheck(TIFF*, int, const char *);
  256. extern  int TIFFCreateDirectory(TIFF*);
  257. extern    int TIFFLastDirectory(TIFF*);
  258. extern    int TIFFSetDirectory(TIFF*, tdir_t);
  259. extern    int TIFFSetSubDirectory(TIFF*, uint32);
  260. extern    int TIFFUnlinkDirectory(TIFF*, tdir_t);
  261. extern    int TIFFSetField(TIFF*, ttag_t, ...);
  262. extern    int TIFFVSetField(TIFF*, ttag_t, va_list);
  263. extern    int TIFFWriteDirectory(TIFF *);
  264. extern    int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int);
  265.  
  266. #if defined(c_plusplus) || defined(__cplusplus)
  267. extern    void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
  268. extern    int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
  269. extern    int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
  270. extern    int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
  271. #else
  272. extern    void TIFFPrintDirectory(TIFF*, FILE*, long);
  273. extern    int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t);
  274. extern    int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t);
  275. extern    int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
  276. #endif
  277.  
  278. extern    int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * );
  279. extern    int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
  280. extern    int TIFFRGBAImageOK(TIFF*, char [1024]);
  281. extern    int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
  282. extern    int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
  283. extern    void TIFFRGBAImageEnd(TIFFRGBAImage*);
  284. extern    TIFF* TIFFOpen(const char*, const char*);
  285. extern    TIFF* TIFFFdOpen(int, const char*, const char*);
  286. extern    TIFF* TIFFClientOpen(const char*, const char*,
  287.         thandle_t,
  288.         TIFFReadWriteProc, TIFFReadWriteProc,
  289.         TIFFSeekProc, TIFFCloseProc,
  290.         TIFFSizeProc,
  291.         TIFFMapFileProc, TIFFUnmapFileProc);
  292. extern    const char* TIFFFileName(TIFF*);
  293. extern    void TIFFError(const char*, const char*, ...);
  294. extern    void TIFFWarning(const char*, const char*, ...);
  295. extern    TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
  296. extern    TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
  297. extern    TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
  298. extern    ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t);
  299. extern    int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t);
  300. extern    ttile_t TIFFNumberOfTiles(TIFF*);
  301. extern    tsize_t TIFFReadTile(TIFF*,
  302.         tdata_t, uint32, uint32, uint32, tsample_t);
  303. extern    tsize_t TIFFWriteTile(TIFF*,
  304.         tdata_t, uint32, uint32, uint32, tsample_t);
  305. extern    tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t);
  306. extern    tstrip_t TIFFNumberOfStrips(TIFF*);
  307. extern    tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
  308. extern    tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
  309. extern    tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
  310. extern    tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
  311. extern    tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
  312. extern    tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
  313. extern    tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
  314. extern    tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
  315. extern    void TIFFSetWriteOffset(TIFF*, toff_t);
  316. extern    void TIFFSwabShort(uint16*);
  317. extern    void TIFFSwabLong(uint32*);
  318. extern    void TIFFSwabDouble(double*);
  319. extern    void TIFFSwabArrayOfShort(uint16*, unsigned long);
  320. extern    void TIFFSwabArrayOfLong(uint32*, unsigned long);
  321. extern    void TIFFSwabArrayOfDouble(double*, unsigned long);
  322. extern    void TIFFReverseBits(unsigned char *, unsigned long);
  323. extern    const unsigned char* TIFFGetBitRevTable(int);
  324. #if defined(__cplusplus)
  325. }
  326. #endif
  327. #endif /* _TIFFIO_ */
  328.