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