]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/tiff/tiffio.h
added possibility to throw different objects and crash directly from the main frame...
[wxWidgets.git] / src / tiff / tiffio.h
... / ...
CommitLineData
1/* $Header$ */
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 * Colour conversion stuff
119 */
120
121/* reference white */
122#define D65_X0 (95.0470F)
123#define D65_Y0 (100.0F)
124#define D65_Z0 (108.8827F)
125
126#define D50_X0 (96.4250F)
127#define D50_Y0 (100.0F)
128#define D50_Z0 (82.4680F)
129
130/* Structure for holding information about a display device. */
131
132typedef unsigned char TIFFRGBValue; /* 8-bit samples */
133
134typedef struct {
135 float d_mat[3][3]; /* XYZ -> luminance matrix */
136 float d_YCR; /* Light o/p for reference white */
137 float d_YCG;
138 float d_YCB;
139 uint32 d_Vrwr; /* Pixel values for ref. white */
140 uint32 d_Vrwg;
141 uint32 d_Vrwb;
142 float d_Y0R; /* Residual light for black pixel */
143 float d_Y0G;
144 float d_Y0B;
145 float d_gammaR; /* Gamma values for the three guns */
146 float d_gammaG;
147 float d_gammaB;
148} TIFFDisplay;
149
150typedef struct { /* YCbCr->RGB support */
151 TIFFRGBValue* clamptab; /* range clamping table */
152 int* Cr_r_tab;
153 int* Cb_b_tab;
154 int32* Cr_g_tab;
155 int32* Cb_g_tab;
156 int32* Y_tab;
157} TIFFYCbCrToRGB;
158
159typedef struct { /* CIE Lab 1976->RGB support */
160 int range; /* Size of conversion table */
161#define CIELABTORGB_TABLE_RANGE 1500
162 float rstep, gstep, bstep;
163 float X0, Y0, Z0; /* Reference white point */
164 TIFFDisplay display;
165 float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
166 float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
167 float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
168} TIFFCIELabToRGB;
169
170extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, TIFFDisplay *, float*);
171extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32,
172 float *, float *, float *);
173extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float,
174 uint32 *, uint32 *, uint32 *);
175
176extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*);
177extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
178 uint32 *, uint32 *, uint32 *);
179
180/*
181 * RGBA-style image support.
182 */
183typedef struct _TIFFRGBAImage TIFFRGBAImage;
184/*
185 * The image reading and conversion routines invoke
186 * ``put routines'' to copy/image/whatever tiles of
187 * raw image data. A default set of routines are
188 * provided to convert/copy raw image data to 8-bit
189 * packed ABGR format rasters. Applications can supply
190 * alternate routines that unpack the data into a
191 * different format or, for example, unpack the data
192 * and draw the unpacked raster on the display.
193 */
194typedef void (*tileContigRoutine)
195 (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
196 unsigned char*);
197typedef void (*tileSeparateRoutine)
198 (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
199 unsigned char*, unsigned char*, unsigned char*, unsigned char*);
200/*
201 * RGBA-reader state.
202 */
203struct _TIFFRGBAImage {
204 TIFF* tif; /* image handle */
205 int stoponerr; /* stop on read error */
206 int isContig; /* data is packed/separate */
207 int alpha; /* type of alpha data present */
208 uint32 width; /* image width */
209 uint32 height; /* image height */
210 uint16 bitspersample; /* image bits/sample */
211 uint16 samplesperpixel; /* image samples/pixel */
212 uint16 orientation; /* image orientation */
213 uint16 req_orientation; /* requested orientation */
214 uint16 photometric; /* image photometric interp */
215 uint16* redcmap; /* colormap pallete */
216 uint16* greencmap;
217 uint16* bluecmap;
218 /* get image data routine */
219 int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
220 union {
221 void (*any)(TIFFRGBAImage*);
222 tileContigRoutine contig;
223 tileSeparateRoutine separate;
224 } put; /* put decoded strip/tile */
225 TIFFRGBValue* Map; /* sample mapping array */
226 uint32** BWmap; /* black&white map */
227 uint32** PALmap; /* palette image map */
228 TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */
229 TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */
230
231 int row_offset;
232 int col_offset;
233};
234
235/*
236 * Macros for extracting components from the
237 * packed ABGR form returned by TIFFReadRGBAImage.
238 */
239#define TIFFGetR(abgr) ((abgr) & 0xff)
240#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
241#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
242#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
243
244/*
245 * A CODEC is a software package that implements decoding,
246 * encoding, or decoding+encoding of a compression algorithm.
247 * The library provides a collection of builtin codecs.
248 * More codecs may be registered through calls to the library
249 * and/or the builtin implementations may be overridden.
250 */
251typedef int (*TIFFInitMethod)(TIFF*, int);
252typedef struct {
253 char* name;
254 uint16 scheme;
255 TIFFInitMethod init;
256} TIFFCodec;
257
258#include <stdio.h>
259#include <stdarg.h>
260
261/* share internal LogLuv conversion routines? */
262#ifndef LOGLUV_PUBLIC
263#define LOGLUV_PUBLIC 1
264#endif
265
266#if defined(__cplusplus)
267extern "C" {
268#endif
269typedef void (*TIFFErrorHandler)(const char*, const char*, va_list);
270typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);
271typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
272typedef int (*TIFFCloseProc)(thandle_t);
273typedef toff_t (*TIFFSizeProc)(thandle_t);
274typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);
275typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);
276typedef void (*TIFFExtendProc)(TIFF*);
277
278extern const char* TIFFGetVersion(void);
279
280extern const TIFFCodec* TIFFFindCODEC(uint16);
281extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
282extern void TIFFUnRegisterCODEC(TIFFCodec*);
283extern int TIFFIsCODECConfigured(uint16);
284
285extern tdata_t _TIFFmalloc(tsize_t);
286extern tdata_t _TIFFrealloc(tdata_t, tsize_t);
287extern void _TIFFmemset(tdata_t, int, tsize_t);
288extern void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t);
289extern int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t);
290extern void _TIFFfree(tdata_t);
291
292extern void TIFFClose(TIFF*);
293extern int TIFFFlush(TIFF*);
294extern int TIFFFlushData(TIFF*);
295extern int TIFFGetField(TIFF*, ttag_t, ...);
296extern int TIFFVGetField(TIFF*, ttag_t, va_list);
297extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...);
298extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list);
299extern int TIFFReadDirectory(TIFF*);
300extern tsize_t TIFFScanlineSize(TIFF*);
301extern tsize_t TIFFRasterScanlineSize(TIFF*);
302extern tsize_t TIFFStripSize(TIFF*);
303extern tsize_t TIFFRawStripSize(TIFF*, tstrip_t);
304extern tsize_t TIFFVStripSize(TIFF*, uint32);
305extern tsize_t TIFFTileRowSize(TIFF*);
306extern tsize_t TIFFTileSize(TIFF*);
307extern tsize_t TIFFVTileSize(TIFF*, uint32);
308extern uint32 TIFFDefaultStripSize(TIFF*, uint32);
309extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
310extern int TIFFFileno(TIFF*);
311extern int TIFFGetMode(TIFF*);
312extern int TIFFIsTiled(TIFF*);
313extern int TIFFIsByteSwapped(TIFF*);
314extern int TIFFIsUpSampled(TIFF*);
315extern int TIFFIsMSB2LSB(TIFF*);
316extern uint32 TIFFCurrentRow(TIFF*);
317extern tdir_t TIFFCurrentDirectory(TIFF*);
318extern tdir_t TIFFNumberOfDirectories(TIFF*);
319extern uint32 TIFFCurrentDirOffset(TIFF*);
320extern tstrip_t TIFFCurrentStrip(TIFF*);
321extern ttile_t TIFFCurrentTile(TIFF*);
322extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t);
323extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t);
324extern int TIFFSetupStrips(TIFF *);
325extern int TIFFWriteCheck(TIFF*, int, const char *);
326extern int TIFFCreateDirectory(TIFF*);
327extern int TIFFLastDirectory(TIFF*);
328extern int TIFFSetDirectory(TIFF*, tdir_t);
329extern int TIFFSetSubDirectory(TIFF*, uint32);
330extern int TIFFUnlinkDirectory(TIFF*, tdir_t);
331extern int TIFFSetField(TIFF*, ttag_t, ...);
332extern int TIFFVSetField(TIFF*, ttag_t, va_list);
333extern int TIFFWriteDirectory(TIFF *);
334extern int TIFFCheckpointDirectory(TIFF *);
335extern int TIFFRewriteDirectory(TIFF *);
336extern int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int);
337
338#if defined(c_plusplus) || defined(__cplusplus)
339extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
340extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
341extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
342extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
343extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*,
344 int = ORIENTATION_BOTLEFT, int = 0);
345#else
346extern void TIFFPrintDirectory(TIFF*, FILE*, long);
347extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t);
348extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t);
349extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
350extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int);
351#endif
352
353extern int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * );
354extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
355extern int TIFFRGBAImageOK(TIFF*, char [1024]);
356extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
357extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
358extern void TIFFRGBAImageEnd(TIFFRGBAImage*);
359extern TIFF* TIFFOpen(const char*, const char*);
360extern TIFF* TIFFFdOpen(int, const char*, const char*);
361extern TIFF* TIFFClientOpen(const char*, const char*,
362 thandle_t,
363 TIFFReadWriteProc, TIFFReadWriteProc,
364 TIFFSeekProc, TIFFCloseProc,
365 TIFFSizeProc,
366 TIFFMapFileProc, TIFFUnmapFileProc);
367extern const char* TIFFFileName(TIFF*);
368extern void TIFFError(const char*, const char*, ...);
369extern void TIFFWarning(const char*, const char*, ...);
370extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
371extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
372extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
373extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t);
374extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t);
375extern ttile_t TIFFNumberOfTiles(TIFF*);
376extern tsize_t TIFFReadTile(TIFF*,
377 tdata_t, uint32, uint32, uint32, tsample_t);
378extern tsize_t TIFFWriteTile(TIFF*,
379 tdata_t, uint32, uint32, uint32, tsample_t);
380extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t);
381extern tstrip_t TIFFNumberOfStrips(TIFF*);
382extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
383extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
384extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
385extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
386extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
387extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
388extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
389extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
390extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */
391extern void TIFFSetWriteOffset(TIFF*, toff_t);
392extern void TIFFSwabShort(uint16*);
393extern void TIFFSwabLong(uint32*);
394extern void TIFFSwabDouble(double*);
395extern void TIFFSwabArrayOfShort(uint16*, unsigned long);
396extern void TIFFSwabArrayOfLong(uint32*, unsigned long);
397extern void TIFFSwabArrayOfDouble(double*, unsigned long);
398extern void TIFFReverseBits(unsigned char *, unsigned long);
399extern const unsigned char* TIFFGetBitRevTable(int);
400
401#ifdef LOGLUV_PUBLIC
402#define U_NEU 0.210526316
403#define V_NEU 0.473684211
404#define UVSCALE 410.
405extern double LogL16toY(int);
406extern double LogL10toY(int);
407extern void XYZtoRGB24(float*, uint8*);
408extern int uv_decode(double*, double*, int);
409extern void LogLuv24toXYZ(uint32, float*);
410extern void LogLuv32toXYZ(uint32, float*);
411#if defined(c_plusplus) || defined(__cplusplus)
412extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
413extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
414extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
415extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER);
416extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER);
417#else
418extern int LogL16fromY(double, int);
419extern int LogL10fromY(double, int);
420extern int uv_encode(double, double, int);
421extern uint32 LogLuv24fromXYZ(float*, int);
422extern uint32 LogLuv32fromXYZ(float*, int);
423#endif
424#endif /* LOGLUV_PUBLIC */
425
426/*
427** New stuff going public in 3.6.x.
428*/
429extern int TIFFGetTagListCount( TIFF * );
430extern ttag_t TIFFGetTagListEntry( TIFF *, int tag_index );
431
432#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
433#define TIFF_VARIABLE -1 /* marker for variable length tags */
434#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */
435#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */
436
437#define FIELD_CUSTOM 65
438
439typedef struct {
440 ttag_t field_tag; /* field's tag */
441 short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
442 short field_writecount; /* write count/TIFF_VARIABLE */
443 TIFFDataType field_type; /* type of associated data */
444 unsigned short field_bit; /* bit in fieldsset bit vector */
445 unsigned char field_oktochange; /* if true, can change while writing */
446 unsigned char field_passcount; /* if true, pass dir count on set */
447 char *field_name; /* ASCII name */
448} TIFFFieldInfo;
449
450typedef struct _TIFFTagValue {
451 const TIFFFieldInfo *info;
452 int count;
453 void *value;
454} TIFFTagValue;
455
456extern void TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int);
457extern const TIFFFieldInfo* TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType);
458extern const TIFFFieldInfo* TIFFFieldWithTag(TIFF*, ttag_t);
459
460typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list);
461typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list);
462typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long);
463
464typedef struct {
465 TIFFVSetMethod vsetfield; /* tag set routine */
466 TIFFVGetMethod vgetfield; /* tag get routine */
467 TIFFPrintMethod printdir; /* directory print routine */
468} TIFFTagMethods;
469
470extern TIFFTagMethods *TIFFAccessTagMethods( TIFF * );
471extern void *TIFFGetClientInfo( TIFF *, const char * );
472extern void TIFFSetClientInfo( TIFF *, void *, const char * );
473
474#if defined(__cplusplus)
475}
476#endif
477#endif /* _TIFFIO_ */