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