Debian Codegraph @

texk/xdvipsk/thirdparty/libtiff/libtiff-src/tiffio.h

raw
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 #ifndef _TIFFIO_
26 #define _TIFFIO_
27
28 /*
29 * TIFF I/O Library Definitions.
30 */
31 #include "tiff.h"
32 #include "tiffvers.h"
33
34 /*
35 * TIFF is defined as an incomplete type to hide the
36 * library's internal data structures from clients.
37 */
38 typedef struct tiff TIFF;
39
40 /*
41 * The following typedefs define the intrinsic size of
42 * data types used in the *exported* interfaces. These
43 * definitions depend on the proper definition of types
44 * in tiff.h. Note also that the varargs interface used
45 * to pass tag types and values uses the types defined in
46 * tiff.h directly.
47 *
48 * NB: ttag_t is unsigned int and not unsigned short because
49 * ANSI C requires that the type before the ellipsis be a
50 * promoted type (i.e. one of int, unsigned int, pointer,
51 * or double) and because we defined pseudo-tags that are
52 * outside the range of legal Aldus-assigned tags.
53 * NB: tsize_t is signed and not unsigned because some functions
54 * return -1.
55 * NB: toff_t is not off_t for many reasons; TIFFs max out at
56 * 32-bit file offsets, and BigTIFF maxes out at 64-bit
57 * offsets being the most important, and to ensure use of
58 * a consistently unsigned type across architectures.
59 * Prior to libtiff 4.0, this was an unsigned 32 bit type.
60 */
61 /*
62 * this is the machine addressing size type, only it's signed, so make it
63 * int32_t on 32bit machines, int64_t on 64bit machines
64 */
65 typedef TIFF_SSIZE_T tmsize_t;
66 #define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
67
68 typedef uint64_t toff_t; /* file offset */
69 /* the following are deprecated and should be replaced by their defining
70 counterparts */
71 typedef uint32_t ttag_t; /* directory tag */
72 typedef uint32_t tdir_t; /* directory index */
73 typedef uint16_t tsample_t; /* sample number */
74 typedef uint32_t tstrile_t; /* strip or tile number */
75 typedef tstrile_t tstrip_t; /* strip number */
76 typedef tstrile_t ttile_t; /* tile number */
77 typedef tmsize_t tsize_t; /* i/o size in bytes */
78 typedef void *tdata_t; /* image data ref */
79
80 /*
81 * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c
82 * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c).
83 *
84 * By default tif_unix.c is assumed.
85 */
86
87 #if defined(_WIN32)
88 #if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && \
89 !defined(USE_WIN32_FILEIO)
90 #define AVOID_WIN32_FILEIO
91 #endif
92 #endif
93
94 #if defined(USE_WIN32_FILEIO)
95 #define VC_EXTRALEAN
96 #include <windows.h>
97 #ifdef _WIN32
98 DECLARE_HANDLE(thandle_t); /* Win32 file handle */
99 #else
100 typedef HFILE thandle_t; /* client data handle */
101 #endif /* _WIN32 */
102 #else
103 typedef void *thandle_t; /* client data handle */
104 #endif /* USE_WIN32_FILEIO */
105
106 /*
107 * Flags to pass to TIFFPrintDirectory to control
108 * printing of data structures that are potentially
109 * very large. Bit-or these flags to enable printing
110 * multiple items.
111 */
112 #define TIFFPRINT_NONE 0x0 /* no extra info */
113 #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */
114 #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */
115 #define TIFFPRINT_COLORMAP 0x4 /* colormap */
116 #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */
117 #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */
118 #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */
119
120 /*
121 * Colour conversion stuff
122 */
123
124 /* reference white */
125 #define D65_X0 (95.0470F)
126 #define D65_Y0 (100.0F)
127 #define D65_Z0 (108.8827F)
128
129 #define D50_X0 (96.4250F)
130 #define D50_Y0 (100.0F)
131 #define D50_Z0 (82.4680F)
132
133 /* Structure for holding information about a display device. */
134
135 typedef unsigned char TIFFRGBValue; /* 8-bit samples */
136
137 typedef struct
138 {
139 float d_mat[3][3]; /* XYZ -> luminance matrix */
140 float d_YCR; /* Light o/p for reference white */
141 float d_YCG;
142 float d_YCB;
143 uint32_t d_Vrwr; /* Pixel values for ref. white */
144 uint32_t d_Vrwg;
145 uint32_t d_Vrwb;
146 float d_Y0R; /* Residual light for black pixel */
147 float d_Y0G;
148 float d_Y0B;
149 float d_gammaR; /* Gamma values for the three guns */
150 float d_gammaG;
151 float d_gammaB;
152 } TIFFDisplay;
153
154 typedef struct
155 { /* YCbCr->RGB support */
156 TIFFRGBValue *clamptab; /* range clamping table */
157 int *Cr_r_tab;
158 int *Cb_b_tab;
159 int32_t *Cr_g_tab;
160 int32_t *Cb_g_tab;
161 int32_t *Y_tab;
162 } TIFFYCbCrToRGB;
163
164 typedef struct
165 { /* CIE Lab 1976->RGB support */
166 int range; /* Size of conversion table */
167 #define CIELABTORGB_TABLE_RANGE 1500
168 float rstep, gstep, bstep;
169 float X0, Y0, Z0; /* Reference white point */
170 TIFFDisplay display;
171 float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
172 float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
173 float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
174 } TIFFCIELabToRGB;
175
176 /*
177 * RGBA-style image support.
178 */
179 typedef struct _TIFFRGBAImage TIFFRGBAImage;
180 /*
181 * The image reading and conversion routines invoke
182 * ``put routines'' to copy/image/whatever tiles of
183 * raw image data. A default set of routines are
184 * provided to convert/copy raw image data to 8-bit
185 * packed ABGR format rasters. Applications can supply
186 * alternate routines that unpack the data into a
187 * different format or, for example, unpack the data
188 * and draw the unpacked raster on the display.
189 */
190 typedef void (*tileContigRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t,
191 uint32_t, uint32_t, uint32_t, int32_t,
192 int32_t, unsigned char *);
193 typedef void (*tileSeparateRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t,
194 uint32_t, uint32_t, uint32_t, int32_t,
195 int32_t, unsigned char *, unsigned char *,
196 unsigned char *, unsigned char *);
197 /*
198 * RGBA-reader state.
199 */
200 struct _TIFFRGBAImage
201 {
202 TIFF *tif; /* image handle */
203 int stoponerr; /* stop on read error */
204 int isContig; /* data is packed/separate */
205 int alpha; /* type of alpha data present */
206 uint32_t width; /* image width */
207 uint32_t height; /* image height */
208 uint16_t bitspersample; /* image bits/sample */
209 uint16_t samplesperpixel; /* image samples/pixel */
210 uint16_t orientation; /* image orientation */
211 uint16_t req_orientation; /* requested orientation */
212 uint16_t photometric; /* image photometric interp */
213 uint16_t *redcmap; /* colormap palette */
214 uint16_t *greencmap;
215 uint16_t *bluecmap;
216 /* get image data routine */
217 int (*get)(TIFFRGBAImage *, uint32_t *, uint32_t, uint32_t);
218 /* put decoded strip/tile */
219 union
220 {
221 void (*any)(TIFFRGBAImage *);
222 tileContigRoutine contig;
223 tileSeparateRoutine separate;
224 } put;
225 TIFFRGBValue *Map; /* sample mapping array */
226 uint32_t **BWmap; /* black&white map */
227 uint32_t **PALmap; /* palette image map */
228 TIFFYCbCrToRGB *ycbcr; /* YCbCr conversion state */
229 TIFFCIELabToRGB *cielab; /* CIE L*a*b conversion state */
230
231 uint8_t *UaToAa; /* Unassociated alpha to associated alpha conversion LUT */
232 uint8_t *Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
233
234 int row_offset;
235 int col_offset;
236 };
237
238 /*
239 * Macros for extracting components from the
240 * packed ABGR form returned by TIFFReadRGBAImage.
241 */
242 #define TIFFGetR(abgr) ((abgr)&0xff)
243 #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
244 #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
245 #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
246
247 /*
248 * A CODEC is a software package that implements decoding,
249 * encoding, or decoding+encoding of a compression algorithm.
250 * The library provides a collection of builtin codecs.
251 * More codecs may be registered through calls to the library
252 * and/or the builtin implementations may be overridden.
253 */
254 typedef int (*TIFFInitMethod)(TIFF *, int);
255 typedef struct
256 {
257 char *name;
258 uint16_t scheme;
259 TIFFInitMethod init;
260 } TIFFCodec;
261
262 typedef struct
263 {
264 uint32_t uNum;
265 uint32_t uDenom;
266 } TIFFRational_t;
267
268 #include <stdarg.h>
269 #include <stdio.h>
270
271 /* share internal LogLuv conversion routines? */
272 #ifndef LOGLUV_PUBLIC
273 #define LOGLUV_PUBLIC 1
274 #endif
275
276 #if defined(__GNUC__) || defined(__clang__) || defined(__attribute__)
277 #define TIFF_ATTRIBUTE(x) __attribute__(x)
278 #else
279 #define TIFF_ATTRIBUTE(x) /*nothing*/
280 #endif
281
282 #if defined(c_plusplus) || defined(__cplusplus)
283 extern "C"
284 {
285 #endif
286 typedef void (*TIFFErrorHandler)(const char *, const char *, va_list);
287 typedef void (*TIFFErrorHandlerExt)(thandle_t, const char *, const char *,
288 va_list);
289 typedef int (*TIFFErrorHandlerExtR)(TIFF *, void *user_data, const char *,
290 const char *, va_list);
291 typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void *, tmsize_t);
292 typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
293 typedef int (*TIFFCloseProc)(thandle_t);
294 typedef toff_t (*TIFFSizeProc)(thandle_t);
295 typedef int (*TIFFMapFileProc)(thandle_t, void **base, toff_t *size);
296 typedef void (*TIFFUnmapFileProc)(thandle_t, void *base, toff_t size);
297 typedef void (*TIFFExtendProc)(TIFF *);
298
299 extern const char *TIFFGetVersion(void);
300
301 extern const TIFFCodec *TIFFFindCODEC(uint16_t);
302 extern TIFFCodec *TIFFRegisterCODEC(uint16_t, const char *, TIFFInitMethod);
303 extern void TIFFUnRegisterCODEC(TIFFCodec *);
304 extern int TIFFIsCODECConfigured(uint16_t);
305 extern TIFFCodec *TIFFGetConfiguredCODECs(void);
306
307 /*
308 * Auxiliary functions.
309 */
310 #ifndef TIFF_DO_NOT_USE_NON_EXT_ALLOC_FUNCTIONS
311 extern void *_TIFFmalloc(tmsize_t s);
312 extern void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz);
313 extern void *_TIFFrealloc(void *p, tmsize_t s);
314 extern void _TIFFfree(void *p);
315 #endif
316 extern void _TIFFmemset(void *p, int v, tmsize_t c);
317 extern void _TIFFmemcpy(void *d, const void *s, tmsize_t c);
318 extern int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c);
319
320 /*
321 ** Stuff, related to tag handling and creating custom tags.
322 */
323 extern int TIFFGetTagListCount(TIFF *);
324 extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index);
325
326 #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
327 #define TIFF_VARIABLE -1 /* marker for variable length tags */
328 #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */
329 #define TIFF_VARIABLE2 -3 /* marker for uint32_t var-length tags */
330
331 #define FIELD_CUSTOM 65
332
333 typedef struct _TIFFField TIFFField;
334 typedef struct _TIFFFieldArray TIFFFieldArray;
335
336 extern const TIFFField *TIFFFindField(TIFF *, uint32_t, TIFFDataType);
337 extern const TIFFField *TIFFFieldWithTag(TIFF *, uint32_t);
338 extern const TIFFField *TIFFFieldWithName(TIFF *, const char *);
339
340 extern uint32_t TIFFFieldTag(const TIFFField *);
341 extern const char *TIFFFieldName(const TIFFField *);
342 extern TIFFDataType TIFFFieldDataType(const TIFFField *);
343 extern int TIFFFieldPassCount(const TIFFField *);
344 extern int TIFFFieldReadCount(const TIFFField *);
345 extern int TIFFFieldWriteCount(const TIFFField *);
346 extern int
347 TIFFFieldSetGetSize(const TIFFField *); /* returns internal storage size of
348 TIFFSetGetFieldType in bytes. */
349 extern int TIFFFieldSetGetCountSize(
350 const TIFFField *); /* returns size of count parameter 0=none,
351 2=uint16_t, 4=uint32_t */
352 extern int TIFFFieldIsAnonymous(const TIFFField *);
353
354 typedef int (*TIFFVSetMethod)(TIFF *, uint32_t, va_list);
355 typedef int (*TIFFVGetMethod)(TIFF *, uint32_t, va_list);
356 typedef void (*TIFFPrintMethod)(TIFF *, FILE *, long);
357
358 typedef struct
359 {
360 TIFFVSetMethod vsetfield; /* tag set routine */
361 TIFFVGetMethod vgetfield; /* tag get routine */
362 TIFFPrintMethod printdir; /* directory print routine */
363 } TIFFTagMethods;
364
365 extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
366 extern void *TIFFGetClientInfo(TIFF *, const char *);
367 extern void TIFFSetClientInfo(TIFF *, void *, const char *);
368
369 extern void TIFFCleanup(TIFF *tif);
370 extern void TIFFClose(TIFF *tif);
371 extern int TIFFFlush(TIFF *tif);
372 extern int TIFFFlushData(TIFF *tif);
373 extern int TIFFGetField(TIFF *tif, uint32_t tag, ...);
374 extern int TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap);
375 extern int TIFFGetFieldDefaulted(TIFF *tif, uint32_t tag, ...);
376 extern int TIFFVGetFieldDefaulted(TIFF *tif, uint32_t tag, va_list ap);
377 extern int TIFFReadDirectory(TIFF *tif);
378 extern int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff,
379 const TIFFFieldArray *infoarray);
380 extern int TIFFReadEXIFDirectory(TIFF *tif, toff_t diroff);
381 extern int TIFFReadGPSDirectory(TIFF *tif, toff_t diroff);
382 extern uint64_t TIFFScanlineSize64(TIFF *tif);
383 extern tmsize_t TIFFScanlineSize(TIFF *tif);
384 extern uint64_t TIFFRasterScanlineSize64(TIFF *tif);
385 extern tmsize_t TIFFRasterScanlineSize(TIFF *tif);
386 extern uint64_t TIFFStripSize64(TIFF *tif);
387 extern tmsize_t TIFFStripSize(TIFF *tif);
388 extern uint64_t TIFFRawStripSize64(TIFF *tif, uint32_t strip);
389 extern tmsize_t TIFFRawStripSize(TIFF *tif, uint32_t strip);
390 extern uint64_t TIFFVStripSize64(TIFF *tif, uint32_t nrows);
391 extern tmsize_t TIFFVStripSize(TIFF *tif, uint32_t nrows);
392 extern uint64_t TIFFTileRowSize64(TIFF *tif);
393 extern tmsize_t TIFFTileRowSize(TIFF *tif);
394 extern uint64_t TIFFTileSize64(TIFF *tif);
395 extern tmsize_t TIFFTileSize(TIFF *tif);
396 extern uint64_t TIFFVTileSize64(TIFF *tif, uint32_t nrows);
397 extern tmsize_t TIFFVTileSize(TIFF *tif, uint32_t nrows);
398 extern uint32_t TIFFDefaultStripSize(TIFF *tif, uint32_t request);
399 extern void TIFFDefaultTileSize(TIFF *, uint32_t *, uint32_t *);
400 extern int TIFFFileno(TIFF *);
401 extern int TIFFSetFileno(TIFF *, int);
402 extern thandle_t TIFFClientdata(TIFF *);
403 extern thandle_t TIFFSetClientdata(TIFF *, thandle_t);
404 extern int TIFFGetMode(TIFF *);
405 extern int TIFFSetMode(TIFF *, int);
406 extern int TIFFIsTiled(TIFF *);
407 extern int TIFFIsByteSwapped(TIFF *);
408 extern int TIFFIsUpSampled(TIFF *);
409 extern int TIFFIsMSB2LSB(TIFF *);
410 extern int TIFFIsBigEndian(TIFF *);
411 extern int TIFFIsBigTIFF(TIFF *);
412 extern TIFFReadWriteProc TIFFGetReadProc(TIFF *);
413 extern TIFFReadWriteProc TIFFGetWriteProc(TIFF *);
414 extern TIFFSeekProc TIFFGetSeekProc(TIFF *);
415 extern TIFFCloseProc TIFFGetCloseProc(TIFF *);
416 extern TIFFSizeProc TIFFGetSizeProc(TIFF *);
417 extern TIFFMapFileProc TIFFGetMapFileProc(TIFF *);
418 extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF *);
419 extern uint32_t TIFFCurrentRow(TIFF *);
420 extern tdir_t TIFFCurrentDirectory(TIFF *);
421 extern tdir_t TIFFNumberOfDirectories(TIFF *);
422 extern uint64_t TIFFCurrentDirOffset(TIFF *);
423 extern uint32_t TIFFCurrentStrip(TIFF *);
424 extern uint32_t TIFFCurrentTile(TIFF *tif);
425 extern int TIFFReadBufferSetup(TIFF *tif, void *bp, tmsize_t size);
426 extern int TIFFWriteBufferSetup(TIFF *tif, void *bp, tmsize_t size);
427 extern int TIFFSetupStrips(TIFF *);
428 extern int TIFFWriteCheck(TIFF *, int, const char *);
429 extern void TIFFFreeDirectory(TIFF *);
430 extern int TIFFCreateDirectory(TIFF *);
431 extern int TIFFCreateCustomDirectory(TIFF *, const TIFFFieldArray *);
432 extern int TIFFCreateEXIFDirectory(TIFF *);
433 extern int TIFFCreateGPSDirectory(TIFF *);
434 extern int TIFFLastDirectory(TIFF *);
435 extern int TIFFSetDirectory(TIFF *, tdir_t);
436 extern int TIFFSetSubDirectory(TIFF *, uint64_t);
437 extern int TIFFUnlinkDirectory(TIFF *, tdir_t);
438 extern int TIFFSetField(TIFF *, uint32_t, ...);
439 extern int TIFFVSetField(TIFF *, uint32_t, va_list);
440 extern int TIFFUnsetField(TIFF *, uint32_t);
441 extern int TIFFWriteDirectory(TIFF *);
442 extern int TIFFWriteCustomDirectory(TIFF *, uint64_t *);
443 extern int TIFFCheckpointDirectory(TIFF *);
444 extern int TIFFRewriteDirectory(TIFF *);
445 extern int TIFFDeferStrileArrayWriting(TIFF *);
446 extern int TIFFForceStrileArrayWriting(TIFF *);
447
448 #if defined(c_plusplus) || defined(__cplusplus)
449 extern void TIFFPrintDirectory(TIFF *, FILE *, long = 0);
450 extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row,
451 uint16_t sample = 0);
452 extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row,
453 uint16_t sample = 0);
454 extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *,
455 int = 0);
456 extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
457 int = ORIENTATION_BOTLEFT, int = 0);
458 #else
459 extern void TIFFPrintDirectory(TIFF *, FILE *, long);
460 extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row,
461 uint16_t sample);
462 extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row,
463 uint16_t sample);
464 extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *, int);
465 extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
466 int, int);
467 #endif
468
469 extern int TIFFReadRGBAStrip(TIFF *, uint32_t, uint32_t *);
470 extern int TIFFReadRGBATile(TIFF *, uint32_t, uint32_t, uint32_t *);
471 extern int TIFFReadRGBAStripExt(TIFF *, uint32_t, uint32_t *,
472 int stop_on_error);
473 extern int TIFFReadRGBATileExt(TIFF *, uint32_t, uint32_t, uint32_t *,
474 int stop_on_error);
475 extern int TIFFRGBAImageOK(TIFF *, char[1024]);
476 extern int TIFFRGBAImageBegin(TIFFRGBAImage *, TIFF *, int, char[1024]);
477 extern int TIFFRGBAImageGet(TIFFRGBAImage *, uint32_t *, uint32_t,
478 uint32_t);
479 extern void TIFFRGBAImageEnd(TIFFRGBAImage *);
480
481 extern const char *TIFFFileName(TIFF *);
482 extern const char *TIFFSetFileName(TIFF *, const char *);
483 extern void TIFFError(const char *, const char *, ...)
484 TIFF_ATTRIBUTE((__format__(__printf__, 2, 3)));
485 extern void TIFFErrorExt(thandle_t, const char *, const char *, ...)
486 TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
487 extern void TIFFWarning(const char *, const char *, ...)
488 TIFF_ATTRIBUTE((__format__(__printf__, 2, 3)));
489 extern void TIFFWarningExt(thandle_t, const char *, const char *, ...)
490 TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
491 extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
492 extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
493 extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
494 extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
495
496 extern void TIFFWarningExtR(TIFF *, const char *, const char *, ...)
497 TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
498 extern void TIFFErrorExtR(TIFF *, const char *, const char *, ...)
499 TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
500
501 typedef struct TIFFOpenOptions TIFFOpenOptions;
502 extern TIFFOpenOptions *TIFFOpenOptionsAlloc(void);
503 extern void TIFFOpenOptionsFree(TIFFOpenOptions *);
504 extern void
505 TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions *opts,
506 tmsize_t max_single_mem_alloc);
507 extern void
508 TIFFOpenOptionsSetMaxCumulatedMemAlloc(TIFFOpenOptions *opts,
509 tmsize_t max_cumulated_mem_alloc);
510 extern void
511 TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts,
512 TIFFErrorHandlerExtR handler,
513 void *errorhandler_user_data);
514 extern void
515 TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions *opts,
516 TIFFErrorHandlerExtR handler,
517 void *warnhandler_user_data);
518
519 extern TIFF *TIFFOpen(const char *, const char *);
520 extern TIFF *TIFFOpenExt(const char *, const char *, TIFFOpenOptions *opts);
521 #ifdef _WIN32
522 extern TIFF *TIFFOpenW(const wchar_t *, const char *);
523 extern TIFF *TIFFOpenWExt(const wchar_t *, const char *,
524 TIFFOpenOptions *opts);
525 #endif /* _WIN32 */
526 extern TIFF *TIFFFdOpen(int, const char *, const char *);
527 extern TIFF *TIFFFdOpenExt(int, const char *, const char *,
528 TIFFOpenOptions *opts);
529 extern TIFF *TIFFClientOpen(const char *, const char *, thandle_t,
530 TIFFReadWriteProc, TIFFReadWriteProc,
531 TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
532 TIFFMapFileProc, TIFFUnmapFileProc);
533 extern TIFF *TIFFClientOpenExt(const char *, const char *, thandle_t,
534 TIFFReadWriteProc, TIFFReadWriteProc,
535 TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
536 TIFFMapFileProc, TIFFUnmapFileProc,
537 TIFFOpenOptions *opts);
538 extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
539 extern uint32_t TIFFComputeTile(TIFF *tif, uint32_t x, uint32_t y,
540 uint32_t z, uint16_t s);
541 extern int TIFFCheckTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z,
542 uint16_t s);
543 extern uint32_t TIFFNumberOfTiles(TIFF *);
544 extern tmsize_t TIFFReadTile(TIFF *tif, void *buf, uint32_t x, uint32_t y,
545 uint32_t z, uint16_t s);
546 extern tmsize_t TIFFWriteTile(TIFF *tif, void *buf, uint32_t x, uint32_t y,
547 uint32_t z, uint16_t s);
548 extern uint32_t TIFFComputeStrip(TIFF *, uint32_t, uint16_t);
549 extern uint32_t TIFFNumberOfStrips(TIFF *);
550 extern tmsize_t TIFFReadEncodedStrip(TIFF *tif, uint32_t strip, void *buf,
551 tmsize_t size);
552 extern tmsize_t TIFFReadRawStrip(TIFF *tif, uint32_t strip, void *buf,
553 tmsize_t size);
554 extern tmsize_t TIFFReadEncodedTile(TIFF *tif, uint32_t tile, void *buf,
555 tmsize_t size);
556 extern tmsize_t TIFFReadRawTile(TIFF *tif, uint32_t tile, void *buf,
557 tmsize_t size);
558 extern int TIFFReadFromUserBuffer(TIFF *tif, uint32_t strile, void *inbuf,
559 tmsize_t insize, void *outbuf,
560 tmsize_t outsize);
561 extern tmsize_t TIFFWriteEncodedStrip(TIFF *tif, uint32_t strip, void *data,
562 tmsize_t cc);
563 extern tmsize_t TIFFWriteRawStrip(TIFF *tif, uint32_t strip, void *data,
564 tmsize_t cc);
565 extern tmsize_t TIFFWriteEncodedTile(TIFF *tif, uint32_t tile, void *data,
566 tmsize_t cc);
567 extern tmsize_t TIFFWriteRawTile(TIFF *tif, uint32_t tile, void *data,
568 tmsize_t cc);
569 extern int TIFFDataWidth(
570 TIFFDataType); /* table of tag datatype widths within TIFF file. */
571 extern void TIFFSetWriteOffset(TIFF *tif, toff_t off);
572 extern void TIFFSwabShort(uint16_t *);
573 extern void TIFFSwabLong(uint32_t *);
574 extern void TIFFSwabLong8(uint64_t *);
575 extern void TIFFSwabFloat(float *);
576 extern void TIFFSwabDouble(double *);
577 extern void TIFFSwabArrayOfShort(uint16_t *wp, tmsize_t n);
578 extern void TIFFSwabArrayOfTriples(uint8_t *tp, tmsize_t n);
579 extern void TIFFSwabArrayOfLong(uint32_t *lp, tmsize_t n);
580 extern void TIFFSwabArrayOfLong8(uint64_t *lp, tmsize_t n);
581 extern void TIFFSwabArrayOfFloat(float *fp, tmsize_t n);
582 extern void TIFFSwabArrayOfDouble(double *dp, tmsize_t n);
583 extern void TIFFReverseBits(uint8_t *cp, tmsize_t n);
584 extern const unsigned char *TIFFGetBitRevTable(int);
585
586 extern uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile);
587 extern uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile);
588 extern uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile,
589 int *pbErr);
590 extern uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile,
591 int *pbErr);
592
593 #ifdef LOGLUV_PUBLIC
594 #define U_NEU 0.210526316
595 #define V_NEU 0.473684211
596 #define UVSCALE 410.
597 extern double LogL16toY(int);
598 extern double LogL10toY(int);
599 extern void XYZtoRGB24(float *, uint8_t *);
600 extern int uv_decode(double *, double *, int);
601 extern void LogLuv24toXYZ(uint32_t, float *);
602 extern void LogLuv32toXYZ(uint32_t, float *);
603 #if defined(c_plusplus) || defined(__cplusplus)
604 extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
605 extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
606 extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
607 extern uint32_t LogLuv24fromXYZ(float *, int = SGILOGENCODE_NODITHER);
608 extern uint32_t LogLuv32fromXYZ(float *, int = SGILOGENCODE_NODITHER);
609 #else
610 extern int LogL16fromY(double, int);
611 extern int LogL10fromY(double, int);
612 extern int uv_encode(double, double, int);
613 extern uint32_t LogLuv24fromXYZ(float *, int);
614 extern uint32_t LogLuv32fromXYZ(float *, int);
615 #endif
616 #endif /* LOGLUV_PUBLIC */
617
618 extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB *, const TIFFDisplay *,
619 float *);
620 extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t,
621 float *, float *, float *);
622 extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32_t *,
623 uint32_t *, uint32_t *);
624
625 extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *, float *, float *);
626 extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t,
627 uint32_t *, uint32_t *, uint32_t *);
628
629 /****************************************************************************
630 * O B S O L E T E D I N T E R F A C E S
631 *
632 * Don't use this stuff in your applications, it may be removed in the
633 *future libtiff versions.
634 ****************************************************************************/
635 typedef struct
636 {
637 ttag_t field_tag; /* field's tag */
638 short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
639 short field_writecount; /* write count/TIFF_VARIABLE */
640 TIFFDataType field_type; /* type of associated data */
641 unsigned short field_bit; /* bit in fieldsset bit vector */
642 unsigned char field_oktochange; /* if true, can change while writing */
643 unsigned char field_passcount; /* if true, pass dir count on set */
644 char *field_name; /* ASCII name */
645 } TIFFFieldInfo;
646
647 extern int TIFFMergeFieldInfo(TIFF *, const TIFFFieldInfo[], uint32_t);
648
649 #if defined(c_plusplus) || defined(__cplusplus)
650 }
651 #endif
652
653 #endif /* _TIFFIO_ */