home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 February / PCWorld_2002-02_cd.bin / Software / Vyzkuste / pdflib / pdflib-4.0.1.sit / pdflib-4.0.1 / tiff / tiffio.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-04  |  12.0 KB  |  314 lines  |  [TEXT/CWIE]

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