source: trunk/third/tiff/libtiff/tiffio.h @ 18174

Revision 18174, 13.7 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18173, which included commits to RCS files with non-trunk default branches.
Line 
1/* $Header: /afs/dev.mit.edu/source/repository/third/tiff/libtiff/tiffio.h,v 1.1.1.1 2002-12-26 02:37:22 ghudson 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#include "tiffvers.h"
35
36/*
37 * TIFF is defined as an incomplete type to hide the
38 * library's internal data structures from clients.
39 */
40typedef struct tiff TIFF;
41
42/*
43 * The following typedefs define the intrinsic size of
44 * data types used in the *exported* interfaces.  These
45 * definitions depend on the proper definition of types
46 * in tiff.h.  Note also that the varargs interface used
47 * to pass tag types and values uses the types defined in
48 * tiff.h directly.
49 *
50 * NB: ttag_t is unsigned int and not unsigned short because
51 *     ANSI C requires that the type before the ellipsis be a
52 *     promoted type (i.e. one of int, unsigned int, pointer,
53 *     or double) and because we defined pseudo-tags that are
54 *     outside the range of legal Aldus-assigned tags.
55 * NB: tsize_t is int32 and not uint32 because some functions
56 *     return -1.
57 * NB: toff_t is not off_t for many reasons; TIFFs max out at
58 *     32-bit file offsets being the most important, and to ensure
59 *     that it is unsigned, rather than signed.
60 */
61typedef uint32 ttag_t;          /* directory tag */
62typedef uint16 tdir_t;          /* directory index */
63typedef uint16 tsample_t;       /* sample number */
64typedef uint32 tstrip_t;        /* strip number */
65typedef uint32 ttile_t;         /* tile number */
66typedef int32 tsize_t;          /* i/o size in bytes */
67typedef void* tdata_t;          /* image data ref */
68typedef uint32 toff_t;          /* file offset */
69
70#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
71#define __WIN32__
72#endif
73
74/*
75 * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c
76 * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c).
77 *
78 * By default tif_win32.c is assumed on windows if not using the cygwin
79 * environment.
80 */
81
82#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
83#  if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILIO)
84#    define USE_WIN32_FILEIO
85#  endif
86#endif
87
88#if defined(USE_WIN32_FILEIO)
89#include <windows.h>
90#ifdef __WIN32__
91DECLARE_HANDLE(thandle_t);      /* Win32 file handle */
92#else
93typedef HFILE thandle_t;        /* client data handle */
94#endif
95#else
96typedef void* thandle_t;        /* client data handle */
97#endif
98
99#ifndef NULL
100#define NULL    0
101#endif
102
103/*
104 * Flags to pass to TIFFPrintDirectory to control
105 * printing of data structures that are potentially
106 * very large.   Bit-or these flags to enable printing
107 * multiple items.
108 */
109#define TIFFPRINT_NONE          0x0             /* no extra info */
110#define TIFFPRINT_STRIPS        0x1             /* strips/tiles info */
111#define TIFFPRINT_CURVES        0x2             /* color/gray response curves */
112#define TIFFPRINT_COLORMAP      0x4             /* colormap */
113#define TIFFPRINT_JPEGQTABLES   0x100           /* JPEG Q matrices */
114#define TIFFPRINT_JPEGACTABLES  0x200           /* JPEG AC tables */
115#define TIFFPRINT_JPEGDCTABLES  0x200           /* JPEG DC tables */
116
117/*
118 * RGBA-style image support.
119 */
120typedef unsigned char TIFFRGBValue;             /* 8-bit samples */
121typedef struct _TIFFRGBAImage TIFFRGBAImage;
122/*
123 * The image reading and conversion routines invoke
124 * ``put routines'' to copy/image/whatever tiles of
125 * raw image data.  A default set of routines are
126 * provided to convert/copy raw image data to 8-bit
127 * packed ABGR format rasters.  Applications can supply
128 * alternate routines that unpack the data into a
129 * different format or, for example, unpack the data
130 * and draw the unpacked raster on the display.
131 */
132typedef void (*tileContigRoutine)
133    (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
134        unsigned char*);
135typedef void (*tileSeparateRoutine)
136    (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
137        unsigned char*, unsigned char*, unsigned char*, unsigned char*);
138/*
139 * RGBA-reader state.
140 */
141typedef struct {                                /* YCbCr->RGB support */
142        TIFFRGBValue* clamptab;                 /* range clamping table */
143        int*    Cr_r_tab;
144        int*    Cb_b_tab;
145        int32*  Cr_g_tab;
146        int32*  Cb_g_tab;
147        float   coeffs[3];                      /* cached for repeated use */
148} TIFFYCbCrToRGB;
149
150struct _TIFFRGBAImage {
151        TIFF*   tif;                            /* image handle */
152        int     stoponerr;                      /* stop on read error */
153        int     isContig;                       /* data is packed/separate */
154        int     alpha;                          /* type of alpha data present */
155        uint32  width;                          /* image width */
156        uint32  height;                         /* image height */
157        uint16  bitspersample;                  /* image bits/sample */
158        uint16  samplesperpixel;                /* image samples/pixel */
159        uint16  orientation;                    /* image orientation */
160        uint16  photometric;                    /* image photometric interp */
161        uint16* redcmap;                        /* colormap pallete */
162        uint16* greencmap;
163        uint16* bluecmap;
164                                                /* get image data routine */
165        int     (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
166        union {
167            void (*any)(TIFFRGBAImage*);
168            tileContigRoutine   contig;
169            tileSeparateRoutine separate;
170        } put;                                  /* put decoded strip/tile */
171        TIFFRGBValue* Map;                      /* sample mapping array */
172        uint32** BWmap;                         /* black&white map */
173        uint32** PALmap;                        /* palette image map */
174        TIFFYCbCrToRGB* ycbcr;                  /* YCbCr conversion state */
175
176        int     row_offset;
177        int     col_offset;
178};
179
180/*
181 * Macros for extracting components from the
182 * packed ABGR form returned by TIFFReadRGBAImage.
183 */
184#define TIFFGetR(abgr)  ((abgr) & 0xff)
185#define TIFFGetG(abgr)  (((abgr) >> 8) & 0xff)
186#define TIFFGetB(abgr)  (((abgr) >> 16) & 0xff)
187#define TIFFGetA(abgr)  (((abgr) >> 24) & 0xff)
188
189/*
190 * A CODEC is a software package that implements decoding,
191 * encoding, or decoding+encoding of a compression algorithm.
192 * The library provides a collection of builtin codecs.
193 * More codecs may be registered through calls to the library
194 * and/or the builtin implementations may be overridden.
195 */
196typedef int (*TIFFInitMethod)(TIFF*, int);
197typedef struct {
198        char*           name;
199        uint16          scheme;
200        TIFFInitMethod  init;
201} TIFFCodec;
202
203#include <stdio.h>
204#include <stdarg.h>
205
206/* share internal LogLuv conversion routines? */
207#ifndef LOGLUV_PUBLIC
208#define LOGLUV_PUBLIC           1       
209#endif
210
211#if defined(__cplusplus)
212extern "C" {
213#endif
214typedef void (*TIFFErrorHandler)(const char*, const char*, va_list);
215typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);
216typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
217typedef int (*TIFFCloseProc)(thandle_t);
218typedef toff_t (*TIFFSizeProc)(thandle_t);
219typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);
220typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);
221typedef void (*TIFFExtendProc)(TIFF*);
222
223extern  const char* TIFFGetVersion(void);
224
225extern  const TIFFCodec* TIFFFindCODEC(uint16);
226extern  TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
227extern  void TIFFUnRegisterCODEC(TIFFCodec*);
228
229extern  tdata_t _TIFFmalloc(tsize_t);
230extern  tdata_t _TIFFrealloc(tdata_t, tsize_t);
231extern  void _TIFFmemset(tdata_t, int, tsize_t);
232extern  void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t);
233extern  int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t);
234extern  void _TIFFfree(tdata_t);
235
236extern  void TIFFClose(TIFF*);
237extern  int TIFFFlush(TIFF*);
238extern  int TIFFFlushData(TIFF*);
239extern  int TIFFGetField(TIFF*, ttag_t, ...);
240extern  int TIFFVGetField(TIFF*, ttag_t, va_list);
241extern  int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...);
242extern  int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list);
243extern  int TIFFReadDirectory(TIFF*);
244extern  tsize_t TIFFScanlineSize(TIFF*);
245extern  tsize_t TIFFRasterScanlineSize(TIFF*);
246extern  tsize_t TIFFStripSize(TIFF*);
247extern  tsize_t TIFFVStripSize(TIFF*, uint32);
248extern  tsize_t TIFFTileRowSize(TIFF*);
249extern  tsize_t TIFFTileSize(TIFF*);
250extern  tsize_t TIFFVTileSize(TIFF*, uint32);
251extern  uint32 TIFFDefaultStripSize(TIFF*, uint32);
252extern  void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
253extern  int TIFFFileno(TIFF*);
254extern  int TIFFGetMode(TIFF*);
255extern  int TIFFIsTiled(TIFF*);
256extern  int TIFFIsByteSwapped(TIFF*);
257extern  int TIFFIsUpSampled(TIFF*);
258extern  int TIFFIsMSB2LSB(TIFF*);
259extern  uint32 TIFFCurrentRow(TIFF*);
260extern  tdir_t TIFFCurrentDirectory(TIFF*);
261extern  tdir_t TIFFNumberOfDirectories(TIFF*);
262extern  uint32 TIFFCurrentDirOffset(TIFF*);
263extern  tstrip_t TIFFCurrentStrip(TIFF*);
264extern  ttile_t TIFFCurrentTile(TIFF*);
265extern  int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t);
266extern  int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t);
267extern  int TIFFWriteCheck(TIFF*, int, const char *);
268extern  int TIFFCreateDirectory(TIFF*);
269extern  int TIFFLastDirectory(TIFF*);
270extern  int TIFFSetDirectory(TIFF*, tdir_t);
271extern  int TIFFSetSubDirectory(TIFF*, uint32);
272extern  int TIFFUnlinkDirectory(TIFF*, tdir_t);
273extern  int TIFFSetField(TIFF*, ttag_t, ...);
274extern  int TIFFVSetField(TIFF*, ttag_t, va_list);
275extern  int TIFFWriteDirectory(TIFF *);
276extern  int TIFFRewriteDirectory(TIFF *);
277extern  int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int);
278
279#if defined(c_plusplus) || defined(__cplusplus)
280extern  void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
281extern  int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
282extern  int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
283extern  int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
284#else
285extern  void TIFFPrintDirectory(TIFF*, FILE*, long);
286extern  int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t);
287extern  int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t);
288extern  int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
289#endif
290
291extern  int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * );
292extern  int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
293extern  int TIFFRGBAImageOK(TIFF*, char [1024]);
294extern  int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
295extern  int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
296extern  void TIFFRGBAImageEnd(TIFFRGBAImage*);
297extern  TIFF* TIFFOpen(const char*, const char*);
298extern  TIFF* TIFFFdOpen(int, const char*, const char*);
299extern  TIFF* TIFFClientOpen(const char*, const char*,
300            thandle_t,
301            TIFFReadWriteProc, TIFFReadWriteProc,
302            TIFFSeekProc, TIFFCloseProc,
303            TIFFSizeProc,
304            TIFFMapFileProc, TIFFUnmapFileProc);
305extern  const char* TIFFFileName(TIFF*);
306extern  void TIFFError(const char*, const char*, ...);
307extern  void TIFFWarning(const char*, const char*, ...);
308extern  TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
309extern  TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
310extern  TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
311extern  ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t);
312extern  int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t);
313extern  ttile_t TIFFNumberOfTiles(TIFF*);
314extern  tsize_t TIFFReadTile(TIFF*,
315            tdata_t, uint32, uint32, uint32, tsample_t);
316extern  tsize_t TIFFWriteTile(TIFF*,
317            tdata_t, uint32, uint32, uint32, tsample_t);
318extern  tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t);
319extern  tstrip_t TIFFNumberOfStrips(TIFF*);
320extern  tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
321extern  tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
322extern  tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
323extern  tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
324extern  tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
325extern  tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
326extern  tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
327extern  tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
328extern  void TIFFSetWriteOffset(TIFF*, toff_t);
329extern  void TIFFSwabShort(uint16*);
330extern  void TIFFSwabLong(uint32*);
331extern  void TIFFSwabDouble(double*);
332extern  void TIFFSwabArrayOfShort(uint16*, unsigned long);
333extern  void TIFFSwabArrayOfLong(uint32*, unsigned long);
334extern  void TIFFSwabArrayOfDouble(double*, unsigned long);
335extern  void TIFFReverseBits(unsigned char *, unsigned long);
336extern  const unsigned char* TIFFGetBitRevTable(int);
337
338#ifdef LOGLUV_PUBLIC
339#define U_NEU           0.210526316
340#define V_NEU           0.473684211
341#define UVSCALE         410.
342extern  double LogL16toY(int);
343extern  double LogL10toY(int);
344extern  void XYZtoRGB24(float*, uint8*);
345extern  int uv_decode(double*, double*, int);
346extern  void LogLuv24toXYZ(uint32, float*);
347extern  void LogLuv32toXYZ(uint32, float*);
348#if defined(c_plusplus) || defined(__cplusplus)
349extern  int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
350extern  int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
351extern  int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
352extern  uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER);
353extern  uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER);
354#else
355extern  int LogL16fromY(double, int);
356extern  int LogL10fromY(double, int);
357extern  int uv_encode(double, double, int);
358extern  uint32 LogLuv24fromXYZ(float*, int);
359extern  uint32 LogLuv32fromXYZ(float*, int);
360#endif
361#endif /* LOGLUV_PUBLIC */
362#if defined(__cplusplus)
363}
364#endif
365#endif /* _TIFFIO_ */
Note: See TracBrowser for help on using the repository browser.