home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / bomb.tar.gz / bomb.tar / bomb / tiffio.h < prev    next >
C/C++ Source or Header  |  1997-04-25  |  12KB  |  303 lines

  1. /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffio.h,v 1.92 1996/01/10 19:33:25 sam Exp $ */
  2.  
  3. /*
  4.  * Copyright (c) 1988-1996 Sam Leffler
  5.  * Copyright (c) 1991-1996 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.  * TIFF is defined as an incomplete type to hide the
  37.  * library's internal data structures from clients.
  38.  */
  39. typedef    struct tiff TIFF;
  40.  
  41. /*
  42.  * The following typedefs define the intrinsic size of
  43.  * data types used in the *exported* interfaces.  These
  44.  * definitions depend on the proper definition of types
  45.  * in tiff.h.  Note also that the varargs interface used
  46.  * pass tag types and values uses the types defined in
  47.  * tiff.h directly.
  48.  *
  49.  * NB: ttag_t is unsigned int and not unsigned short because
  50.  *     ANSI C requires that the type before the ellipsis be a
  51.  *     promoted type (i.e. one of int, unsigned int, pointer,
  52.  *     or double) and because we defined pseudo-tags that are
  53.  *     outside the range of legal Aldus-assigned tags.
  54.  * NB: tsize_t is int32 and not uint32 because some functions
  55.  *     return -1.
  56.  * NB: toff_t is not off_t for many reasons; TIFFs max out at
  57.  *     32-bit file offsets being the most important
  58.  */
  59. typedef    unsigned int ttag_t;    /* directory tag */
  60. typedef    uint16 tdir_t;        /* directory index */
  61. typedef    uint16 tsample_t;    /* sample number */
  62. typedef    uint32 tstrip_t;    /* strip number */
  63. typedef uint32 ttile_t;        /* tile number */
  64. typedef    int32 tsize_t;        /* i/o size in bytes */
  65. #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
  66. #include <windows.h>
  67. #ifdef __WIN32__
  68. DECLARE_HANDLE(thandle_t);    /* Win32 file handle */
  69. #else
  70. typedef    HFILE thandle_t;    /* client data handle */
  71. #endif
  72. #else
  73. typedef    void* thandle_t;    /* client data handle */
  74. #endif
  75. typedef    void* tdata_t;        /* image data ref */
  76. typedef    int32 toff_t;        /* file offset */
  77.  
  78. #ifndef NULL
  79. #define    NULL    0
  80. #endif
  81.  
  82. /*
  83.  * Flags to pass to TIFFPrintDirectory to control
  84.  * printing of data structures that are potentially
  85.  * very large.   Bit-or these flags to enable printing
  86.  * multiple items.
  87.  */
  88. #define    TIFFPRINT_NONE        0x0        /* no extra info */
  89. #define    TIFFPRINT_STRIPS    0x1        /* strips/tiles info */
  90. #define    TIFFPRINT_CURVES    0x2        /* color/gray response curves */
  91. #define    TIFFPRINT_COLORMAP    0x4        /* colormap */
  92. #define    TIFFPRINT_JPEGQTABLES    0x100        /* JPEG Q matrices */
  93. #define    TIFFPRINT_JPEGACTABLES    0x200        /* JPEG AC tables */
  94. #define    TIFFPRINT_JPEGDCTABLES    0x200        /* JPEG DC tables */
  95.  
  96. /*
  97.  * RGBA-style image support.
  98.  */
  99. typedef    unsigned char TIFFRGBValue;        /* 8-bit samples */
  100. typedef struct _TIFFRGBAImage TIFFRGBAImage;
  101. /*
  102.  * The image reading and conversion routines invoke
  103.  * ``put routines'' to copy/image/whatever tiles of
  104.  * raw image data.  A default set of routines are 
  105.  * provided to convert/copy raw image data to 8-bit
  106.  * packed ABGR format rasters.  Applications can supply
  107.  * alternate routines that unpack the data into a
  108.  * different format or, for example, unpack the data
  109.  * and draw the unpacked raster on the display.
  110.  */
  111. typedef void (*tileContigRoutine)
  112.     (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
  113.     unsigned char*);
  114. typedef void (*tileSeparateRoutine)
  115.     (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
  116.     unsigned char*, unsigned char*, unsigned char*, unsigned char*);
  117. /*
  118.  * RGBA-reader state.
  119.  */
  120. typedef struct {                /* YCbCr->RGB support */
  121.     TIFFRGBValue* clamptab;            /* range clamping table */
  122.     int*    Cr_r_tab;
  123.     int*    Cb_b_tab;
  124.     int32*    Cr_g_tab;
  125.     int32*    Cb_g_tab;
  126.     float    coeffs[3];            /* cached for repeated use */
  127. } TIFFYCbCrToRGB;
  128.  
  129. struct _TIFFRGBAImage {
  130.     TIFF*    tif;                /* image handle */
  131.     int    stoponerr;            /* stop on read error */
  132.     int    isContig;            /* data is packed/separate */
  133.     int    alpha;                /* type of alpha data present */
  134.     uint32    width;                /* image width */
  135.     uint32    height;                /* image height */
  136.     uint16    bitspersample;            /* image bits/sample */
  137.     uint16    samplesperpixel;        /* image samples/pixel */
  138.     uint16    orientation;            /* image orientation */
  139.     uint16    photometric;            /* image photometric interp */
  140.     uint16*    redcmap;            /* colormap pallete */
  141.     uint16*    greencmap;
  142.     uint16*    bluecmap;
  143.                         /* get image data routine */
  144.     int    (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
  145.     union {
  146.         void (*any)(TIFFRGBAImage*);
  147.         tileContigRoutine    contig;
  148.         tileSeparateRoutine    separate;
  149.     } put;                    /* put decoded strip/tile */
  150.     TIFFRGBValue* Map;            /* sample mapping array */
  151.     uint32** BWmap;                /* black&white map */
  152.     uint32** PALmap;            /* palette image map */
  153.     TIFFYCbCrToRGB* ycbcr;            /* YCbCr conversion state */
  154. };
  155.  
  156. /*
  157.  * Macros for extracting components from the
  158.  * packed ABGR form returned by TIFFReadRGBAImage.
  159.  */
  160. #define    TIFFGetR(abgr)    ((abgr) & 0xff)
  161. #define    TIFFGetG(abgr)    (((abgr) >> 8) & 0xff)
  162. #define    TIFFGetB(abgr)    (((abgr) >> 16) & 0xff)
  163. #define    TIFFGetA(abgr)    (((abgr) >> 24) & 0xff)
  164.  
  165. /*
  166.  * A CODEC is a software package that implements decoding,
  167.  * encoding, or decoding+encoding of a compression algorithm.
  168.  * The library provides a collection of builtin codecs.
  169.  * More codecs may be registered through calls to the library
  170.  * and/or the builtin implementations may be overridden.
  171.  */
  172. typedef    int (*TIFFInitMethod)(TIFF*, int);
  173. typedef struct {
  174.     char*        name;
  175.     uint16        scheme;
  176.     TIFFInitMethod    init;
  177. } TIFFCodec;
  178.  
  179. #include <stdio.h>
  180. #include <stdarg.h>
  181.  
  182. #if defined(__cplusplus)
  183. extern "C" {
  184. #endif
  185. typedef    void (*TIFFErrorHandler)(const char*, const char*, va_list);
  186. typedef    tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);
  187. typedef    toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
  188. typedef    int (*TIFFCloseProc)(thandle_t);
  189. typedef    toff_t (*TIFFSizeProc)(thandle_t);
  190. typedef    int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);
  191. typedef    void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);
  192. typedef    void (*TIFFExtendProc)(TIFF*); 
  193.  
  194. extern    const char* TIFFGetVersion(void);
  195.  
  196. extern    const TIFFCodec* TIFFFindCODEC(uint16);
  197. extern    TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
  198. extern    void TIFFUnRegisterCODEC(TIFFCodec*);
  199.  
  200. extern    tdata_t _TIFFmalloc(tsize_t);
  201. extern    tdata_t _TIFFrealloc(tdata_t, tsize_t);
  202. extern    void _TIFFmemset(tdata_t, int, tsize_t);
  203. extern    void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t);
  204. extern    int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t);
  205. extern    void _TIFFfree(tdata_t);
  206.  
  207. extern    void TIFFClose(TIFF*);
  208. extern    int TIFFFlush(TIFF*);
  209. extern    int TIFFFlushData(TIFF*);
  210. extern    int TIFFGetField(TIFF*, ttag_t, ...);
  211. extern    int TIFFVGetField(TIFF*, ttag_t, va_list);
  212. extern    int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...);
  213. extern    int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list);
  214. extern    int TIFFReadDirectory(TIFF*);
  215. extern    tsize_t TIFFScanlineSize(TIFF*);
  216. extern    tsize_t TIFFRasterScanlineSize(TIFF*);
  217. extern    tsize_t TIFFStripSize(TIFF*);
  218. extern    tsize_t TIFFVStripSize(TIFF*, uint32);
  219. extern    tsize_t TIFFTileRowSize(TIFF*);
  220. extern    tsize_t TIFFTileSize(TIFF*);
  221. extern    tsize_t TIFFVTileSize(TIFF*, uint32);
  222. extern    uint32 TIFFDefaultStripSize(TIFF*, uint32);
  223. extern    void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
  224. extern    int TIFFFileno(TIFF*);
  225. extern    int TIFFGetMode(TIFF*);
  226. extern    int TIFFIsTiled(TIFF*);
  227. extern    int TIFFIsByteSwapped(TIFF*);
  228. extern    int TIFFIsUpSampled(TIFF*);
  229. extern    int TIFFIsMSB2LSB(TIFF*);
  230. extern    uint32 TIFFCurrentRow(TIFF*);
  231. extern    tdir_t TIFFCurrentDirectory(TIFF*);
  232. extern    uint32 TIFFCurrentDirOffset(TIFF*);
  233. extern    tstrip_t TIFFCurrentStrip(TIFF*);
  234. extern    ttile_t TIFFCurrentTile(TIFF*);
  235. extern    int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t);
  236. extern    int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t);
  237. extern    int TIFFLastDirectory(TIFF*);
  238. extern    int TIFFSetDirectory(TIFF*, tdir_t);
  239. extern    int TIFFSetSubDirectory(TIFF*, uint32);
  240. extern    int TIFFUnlinkDirectory(TIFF*, tdir_t);
  241. extern    int TIFFSetField(TIFF*, ttag_t, ...);
  242. extern    int TIFFVSetField(TIFF*, ttag_t, va_list);
  243. extern    int TIFFWriteDirectory(TIFF *);
  244. #if defined(c_plusplus) || defined(__cplusplus)
  245. extern    void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
  246. extern    int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
  247. extern    int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
  248. extern    int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
  249. #else
  250. extern    void TIFFPrintDirectory(TIFF*, FILE*, long);
  251. extern    int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t);
  252. extern    int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t);
  253. extern    int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
  254. #endif
  255. extern    int TIFFRGBAImageOK(TIFF*, char [1024]);
  256. extern    int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
  257. extern    int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
  258. extern    void TIFFRGBAImageEnd(TIFFRGBAImage*);
  259. extern    TIFF* TIFFOpen(const char*, const char*);
  260. extern    TIFF* TIFFFdOpen(int, const char*, const char*);
  261. extern    TIFF* TIFFClientOpen(const char*, const char*,
  262.         thandle_t,
  263.         TIFFReadWriteProc, TIFFReadWriteProc,
  264.         TIFFSeekProc, TIFFCloseProc,
  265.         TIFFSizeProc,
  266.         TIFFMapFileProc, TIFFUnmapFileProc);
  267. extern    const char* TIFFFileName(TIFF*);
  268. extern    void TIFFError(const char*, const char*, ...);
  269. extern    void TIFFWarning(const char*, const char*, ...);
  270. extern    TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
  271. extern    TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
  272. extern    TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
  273. extern    ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t);
  274. extern    int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t);
  275. extern    ttile_t TIFFNumberOfTiles(TIFF*);
  276. extern    tsize_t TIFFReadTile(TIFF*,
  277.         tdata_t, uint32, uint32, uint32, tsample_t);
  278. extern    tsize_t TIFFWriteTile(TIFF*,
  279.         tdata_t, uint32, uint32, uint32, tsample_t);
  280. extern    tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t);
  281. extern    tstrip_t TIFFNumberOfStrips(TIFF*);
  282. extern    tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
  283. extern    tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
  284. extern    tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
  285. extern    tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
  286. extern    tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
  287. extern    tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
  288. extern    tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
  289. extern    tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
  290. extern    void TIFFSetWriteOffset(TIFF*, toff_t);
  291. extern    void TIFFSwabShort(uint16*);
  292. extern    void TIFFSwabLong(uint32*);
  293. extern    void TIFFSwabDouble(double*);
  294. extern    void TIFFSwabArrayOfShort(uint16*, unsigned long);
  295. extern    void TIFFSwabArrayOfLong(uint32*, unsigned long);
  296. extern    void TIFFSwabArrayOfDouble(double*, unsigned long);
  297. extern    void TIFFReverseBits(unsigned char *, unsigned long);
  298. extern    const unsigned char* TIFFGetBitRevTable(int);
  299. #if defined(__cplusplus)
  300. }
  301. #endif
  302. #endif /* _TIFFIO_ */
  303.