| 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 | #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) |
| 81 | #define __WIN32__ |
| 82 | #endif |
| 83 | |
| 84 | /* |
| 85 | * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c |
| 86 | * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). |
| 87 | * |
| 88 | * By default tif_unix.c is assumed. |
| 89 | */ |
| 90 | |
| 91 | #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) |
| 92 | #if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && \ |
| 93 | !defined(USE_WIN32_FILEIO) |
| 94 | #define AVOID_WIN32_FILEIO |
| 95 | #endif |
| 96 | #endif |
| 97 | |
| 98 | #if defined(USE_WIN32_FILEIO) |
| 99 | #define VC_EXTRALEAN |
| 100 | #include <windows.h> |
| 101 | #ifdef __WIN32__ |
| 102 | DECLARE_HANDLE(thandle_t); /* Win32 file handle */ |
| 103 | #else |
| 104 | typedef HFILE thandle_t; /* client data handle */ |
| 105 | #endif /* __WIN32__ */ |
| 106 | #else |
| 107 | typedef void *thandle_t; /* client data handle */ |
| 108 | #endif /* USE_WIN32_FILEIO */ |
| 109 | |
| 110 | /* |
| 111 | * Flags to pass to TIFFPrintDirectory to control |
| 112 | * printing of data structures that are potentially |
| 113 | * very large. Bit-or these flags to enable printing |
| 114 | * multiple items. |
| 115 | */ |
| 116 | #define TIFFPRINT_NONE 0x0 /* no extra info */ |
| 117 | #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ |
| 118 | #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ |
| 119 | #define TIFFPRINT_COLORMAP 0x4 /* colormap */ |
| 120 | #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ |
| 121 | #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ |
| 122 | #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ |
| 123 | |
| 124 | /* |
| 125 | * Colour conversion stuff |
| 126 | */ |
| 127 | |
| 128 | /* reference white */ |
| 129 | #define D65_X0 (95.0470F) |
| 130 | #define D65_Y0 (100.0F) |
| 131 | #define D65_Z0 (108.8827F) |
| 132 | |
| 133 | #define D50_X0 (96.4250F) |
| 134 | #define D50_Y0 (100.0F) |
| 135 | #define D50_Z0 (82.4680F) |
| 136 | |
| 137 | /* Structure for holding information about a display device. */ |
| 138 | |
| 139 | typedef unsigned char TIFFRGBValue; /* 8-bit samples */ |
| 140 | |
| 141 | typedef struct |
| 142 | { |
| 143 | float d_mat[3][3]; /* XYZ -> luminance matrix */ |
| 144 | float d_YCR; /* Light o/p for reference white */ |
| 145 | float d_YCG; |
| 146 | float d_YCB; |
| 147 | uint32_t d_Vrwr; /* Pixel values for ref. white */ |
| 148 | uint32_t d_Vrwg; |
| 149 | uint32_t d_Vrwb; |
| 150 | float d_Y0R; /* Residual light for black pixel */ |
| 151 | float d_Y0G; |
| 152 | float d_Y0B; |
| 153 | float d_gammaR; /* Gamma values for the three guns */ |
| 154 | float d_gammaG; |
| 155 | float d_gammaB; |
| 156 | } TIFFDisplay; |
| 157 | |
| 158 | typedef struct |
| 159 | { /* YCbCr->RGB support */ |
| 160 | TIFFRGBValue *clamptab; /* range clamping table */ |
| 161 | int *Cr_r_tab; |
| 162 | int *Cb_b_tab; |
| 163 | int32_t *Cr_g_tab; |
| 164 | int32_t *Cb_g_tab; |
| 165 | int32_t *Y_tab; |
| 166 | } TIFFYCbCrToRGB; |
| 167 | |
| 168 | typedef struct |
| 169 | { /* CIE Lab 1976->RGB support */ |
| 170 | int range; /* Size of conversion table */ |
| 171 | #define CIELABTORGB_TABLE_RANGE 1500 |
| 172 | float rstep, gstep, bstep; |
| 173 | float X0, Y0, Z0; /* Reference white point */ |
| 174 | TIFFDisplay display; |
| 175 | float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ |
| 176 | float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ |
| 177 | float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ |
| 178 | } TIFFCIELabToRGB; |
| 179 | |
| 180 | /* |
| 181 | * RGBA-style image support. |
| 182 | */ |
| 183 | typedef 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 | */ |
| 194 | typedef void (*tileContigRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t, |
| 195 | uint32_t, uint32_t, uint32_t, int32_t, |
| 196 | int32_t, unsigned char *); |
| 197 | typedef void (*tileSeparateRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t, |
| 198 | uint32_t, uint32_t, uint32_t, int32_t, |
| 199 | int32_t, unsigned char *, unsigned char *, |
| 200 | unsigned char *, unsigned char *); |
| 201 | /* |
| 202 | * RGBA-reader state. |
| 203 | */ |
| 204 | struct _TIFFRGBAImage |
| 205 | { |
| 206 | TIFF *tif; /* image handle */ |
| 207 | int stoponerr; /* stop on read error */ |
| 208 | int isContig; /* data is packed/separate */ |
| 209 | int alpha; /* type of alpha data present */ |
| 210 | uint32_t width; /* image width */ |
| 211 | uint32_t height; /* image height */ |
| 212 | uint16_t bitspersample; /* image bits/sample */ |
| 213 | uint16_t samplesperpixel; /* image samples/pixel */ |
| 214 | uint16_t orientation; /* image orientation */ |
| 215 | uint16_t req_orientation; /* requested orientation */ |
| 216 | uint16_t photometric; /* image photometric interp */ |
| 217 | uint16_t *redcmap; /* colormap palette */ |
| 218 | uint16_t *greencmap; |
| 219 | uint16_t *bluecmap; |
| 220 | /* get image data routine */ |
| 221 | int (*get)(TIFFRGBAImage *, uint32_t *, uint32_t, uint32_t); |
| 222 | /* put decoded strip/tile */ |
| 223 | union |
| 224 | { |
| 225 | void (*any)(TIFFRGBAImage *); |
| 226 | tileContigRoutine contig; |
| 227 | tileSeparateRoutine separate; |
| 228 | } put; |
| 229 | TIFFRGBValue *Map; /* sample mapping array */ |
| 230 | uint32_t **BWmap; /* black&white map */ |
| 231 | uint32_t **PALmap; /* palette image map */ |
| 232 | TIFFYCbCrToRGB *ycbcr; /* YCbCr conversion state */ |
| 233 | TIFFCIELabToRGB *cielab; /* CIE L*a*b conversion state */ |
| 234 | |
| 235 | uint8_t *UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ |
| 236 | uint8_t *Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ |
| 237 | |
| 238 | int row_offset; |
| 239 | int col_offset; |
| 240 | }; |
| 241 | |
| 242 | /* |
| 243 | * Macros for extracting components from the |
| 244 | * packed ABGR form returned by TIFFReadRGBAImage. |
| 245 | */ |
| 246 | #define TIFFGetR(abgr) ((abgr)&0xff) |
| 247 | #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) |
| 248 | #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) |
| 249 | #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) |
| 250 | |
| 251 | /* |
| 252 | * A CODEC is a software package that implements decoding, |
| 253 | * encoding, or decoding+encoding of a compression algorithm. |
| 254 | * The library provides a collection of builtin codecs. |
| 255 | * More codecs may be registered through calls to the library |
| 256 | * and/or the builtin implementations may be overridden. |
| 257 | */ |
| 258 | typedef int (*TIFFInitMethod)(TIFF *, int); |
| 259 | typedef struct |
| 260 | { |
| 261 | char *name; |
| 262 | uint16_t scheme; |
| 263 | TIFFInitMethod init; |
| 264 | } TIFFCodec; |
| 265 | |
| 266 | typedef struct |
| 267 | { |
| 268 | uint32_t uNum; |
| 269 | uint32_t uDenom; |
| 270 | } TIFFRational_t; |
| 271 | |
| 272 | #include <stdarg.h> |
| 273 | #include <stdio.h> |
| 274 | |
| 275 | /* share internal LogLuv conversion routines? */ |
| 276 | #ifndef LOGLUV_PUBLIC |
| 277 | #define LOGLUV_PUBLIC 1 |
| 278 | #endif |
| 279 | |
| 280 | #if defined(__GNUC__) || defined(__attribute__) |
| 281 | #define TIFF_ATTRIBUTE(x) __attribute__(x) |
| 282 | #else |
| 283 | #define TIFF_ATTRIBUTE(x) /*nothing*/ |
| 284 | #endif |
| 285 | |
| 286 | #if defined(c_plusplus) || defined(__cplusplus) |
| 287 | extern "C" |
| 288 | { |
| 289 | #endif |
| 290 | typedef void (*TIFFErrorHandler)(const char *, const char *, va_list); |
| 291 | typedef void (*TIFFErrorHandlerExt)(thandle_t, const char *, const char *, |
| 292 | va_list); |
| 293 | typedef int (*TIFFErrorHandlerExtR)(TIFF *, void *user_data, const char *, |
| 294 | const char *, va_list); |
| 295 | typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void *, tmsize_t); |
| 296 | typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); |
| 297 | typedef int (*TIFFCloseProc)(thandle_t); |
| 298 | typedef toff_t (*TIFFSizeProc)(thandle_t); |
| 299 | typedef int (*TIFFMapFileProc)(thandle_t, void **base, toff_t *size); |
| 300 | typedef void (*TIFFUnmapFileProc)(thandle_t, void *base, toff_t size); |
| 301 | typedef void (*TIFFExtendProc)(TIFF *); |
| 302 | |
| 303 | extern const char *TIFFGetVersion(void); |
| 304 | |
| 305 | extern const TIFFCodec *TIFFFindCODEC(uint16_t); |
| 306 | extern TIFFCodec *TIFFRegisterCODEC(uint16_t, const char *, TIFFInitMethod); |
| 307 | extern void TIFFUnRegisterCODEC(TIFFCodec *); |
| 308 | extern int TIFFIsCODECConfigured(uint16_t); |
| 309 | extern TIFFCodec *TIFFGetConfiguredCODECs(void); |
| 310 | |
| 311 | /* |
| 312 | * Auxiliary functions. |
| 313 | */ |
| 314 | |
| 315 | extern void *_TIFFmalloc(tmsize_t s); |
| 316 | extern void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz); |
| 317 | extern void *_TIFFrealloc(void *p, tmsize_t s); |
| 318 | extern void _TIFFmemset(void *p, int v, tmsize_t c); |
| 319 | extern void _TIFFmemcpy(void *d, const void *s, tmsize_t c); |
| 320 | extern int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c); |
| 321 | extern void _TIFFfree(void *p); |
| 322 | |
| 323 | /* |
| 324 | ** Stuff, related to tag handling and creating custom tags. |
| 325 | */ |
| 326 | extern int TIFFGetTagListCount(TIFF *); |
| 327 | extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index); |
| 328 | |
| 329 | #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ |
| 330 | #define TIFF_VARIABLE -1 /* marker for variable length tags */ |
| 331 | #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ |
| 332 | #define TIFF_VARIABLE2 -3 /* marker for uint32_t var-length tags */ |
| 333 | |
| 334 | #define FIELD_CUSTOM 65 |
| 335 | |
| 336 | typedef struct _TIFFField TIFFField; |
| 337 | typedef struct _TIFFFieldArray TIFFFieldArray; |
| 338 | |
| 339 | extern const TIFFField *TIFFFindField(TIFF *, uint32_t, TIFFDataType); |
| 340 | extern const TIFFField *TIFFFieldWithTag(TIFF *, uint32_t); |
| 341 | extern const TIFFField *TIFFFieldWithName(TIFF *, const char *); |
| 342 | |
| 343 | extern uint32_t TIFFFieldTag(const TIFFField *); |
| 344 | extern const char *TIFFFieldName(const TIFFField *); |
| 345 | extern TIFFDataType TIFFFieldDataType(const TIFFField *); |
| 346 | extern int TIFFFieldPassCount(const TIFFField *); |
| 347 | extern int TIFFFieldReadCount(const TIFFField *); |
| 348 | extern int TIFFFieldWriteCount(const TIFFField *); |
| 349 | extern int |
| 350 | TIFFFieldSetGetSize(const TIFFField *); /* returns internal storage size of |
| 351 | TIFFSetGetFieldType in bytes. */ |
| 352 | extern int TIFFFieldSetGetCountSize( |
| 353 | const TIFFField *); /* returns size of count parameter 0=none, |
| 354 | 2=uint16_t, 4=uint32_t */ |
| 355 | extern int TIFFFieldIsAnonymous(const TIFFField *); |
| 356 | |
| 357 | typedef int (*TIFFVSetMethod)(TIFF *, uint32_t, va_list); |
| 358 | typedef int (*TIFFVGetMethod)(TIFF *, uint32_t, va_list); |
| 359 | typedef void (*TIFFPrintMethod)(TIFF *, FILE *, long); |
| 360 | |
| 361 | typedef struct |
| 362 | { |
| 363 | TIFFVSetMethod vsetfield; /* tag set routine */ |
| 364 | TIFFVGetMethod vgetfield; /* tag get routine */ |
| 365 | TIFFPrintMethod printdir; /* directory print routine */ |
| 366 | } TIFFTagMethods; |
| 367 | |
| 368 | extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); |
| 369 | extern void *TIFFGetClientInfo(TIFF *, const char *); |
| 370 | extern void TIFFSetClientInfo(TIFF *, void *, const char *); |
| 371 | |
| 372 | extern void TIFFCleanup(TIFF *tif); |
| 373 | extern void TIFFClose(TIFF *tif); |
| 374 | extern int TIFFFlush(TIFF *tif); |
| 375 | extern int TIFFFlushData(TIFF *tif); |
| 376 | extern int TIFFGetField(TIFF *tif, uint32_t tag, ...); |
| 377 | extern int TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap); |
| 378 | extern int TIFFGetFieldDefaulted(TIFF *tif, uint32_t tag, ...); |
| 379 | extern int TIFFVGetFieldDefaulted(TIFF *tif, uint32_t tag, va_list ap); |
| 380 | extern int TIFFReadDirectory(TIFF *tif); |
| 381 | extern int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff, |
| 382 | const TIFFFieldArray *infoarray); |
| 383 | extern int TIFFReadEXIFDirectory(TIFF *tif, toff_t diroff); |
| 384 | extern int TIFFReadGPSDirectory(TIFF *tif, toff_t diroff); |
| 385 | extern uint64_t TIFFScanlineSize64(TIFF *tif); |
| 386 | extern tmsize_t TIFFScanlineSize(TIFF *tif); |
| 387 | extern uint64_t TIFFRasterScanlineSize64(TIFF *tif); |
| 388 | extern tmsize_t TIFFRasterScanlineSize(TIFF *tif); |
| 389 | extern uint64_t TIFFStripSize64(TIFF *tif); |
| 390 | extern tmsize_t TIFFStripSize(TIFF *tif); |
| 391 | extern uint64_t TIFFRawStripSize64(TIFF *tif, uint32_t strip); |
| 392 | extern tmsize_t TIFFRawStripSize(TIFF *tif, uint32_t strip); |
| 393 | extern uint64_t TIFFVStripSize64(TIFF *tif, uint32_t nrows); |
| 394 | extern tmsize_t TIFFVStripSize(TIFF *tif, uint32_t nrows); |
| 395 | extern uint64_t TIFFTileRowSize64(TIFF *tif); |
| 396 | extern tmsize_t TIFFTileRowSize(TIFF *tif); |
| 397 | extern uint64_t TIFFTileSize64(TIFF *tif); |
| 398 | extern tmsize_t TIFFTileSize(TIFF *tif); |
| 399 | extern uint64_t TIFFVTileSize64(TIFF *tif, uint32_t nrows); |
| 400 | extern tmsize_t TIFFVTileSize(TIFF *tif, uint32_t nrows); |
| 401 | extern uint32_t TIFFDefaultStripSize(TIFF *tif, uint32_t request); |
| 402 | extern void TIFFDefaultTileSize(TIFF *, uint32_t *, uint32_t *); |
| 403 | extern int TIFFFileno(TIFF *); |
| 404 | extern int TIFFSetFileno(TIFF *, int); |
| 405 | extern thandle_t TIFFClientdata(TIFF *); |
| 406 | extern thandle_t TIFFSetClientdata(TIFF *, thandle_t); |
| 407 | extern int TIFFGetMode(TIFF *); |
| 408 | extern int TIFFSetMode(TIFF *, int); |
| 409 | extern int TIFFIsTiled(TIFF *); |
| 410 | extern int TIFFIsByteSwapped(TIFF *); |
| 411 | extern int TIFFIsUpSampled(TIFF *); |
| 412 | extern int TIFFIsMSB2LSB(TIFF *); |
| 413 | extern int TIFFIsBigEndian(TIFF *); |
| 414 | extern int TIFFIsBigTIFF(TIFF *); |
| 415 | extern TIFFReadWriteProc TIFFGetReadProc(TIFF *); |
| 416 | extern TIFFReadWriteProc TIFFGetWriteProc(TIFF *); |
| 417 | extern TIFFSeekProc TIFFGetSeekProc(TIFF *); |
| 418 | extern TIFFCloseProc TIFFGetCloseProc(TIFF *); |
| 419 | extern TIFFSizeProc TIFFGetSizeProc(TIFF *); |
| 420 | extern TIFFMapFileProc TIFFGetMapFileProc(TIFF *); |
| 421 | extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF *); |
| 422 | extern uint32_t TIFFCurrentRow(TIFF *); |
| 423 | extern tdir_t TIFFCurrentDirectory(TIFF *); |
| 424 | extern tdir_t TIFFNumberOfDirectories(TIFF *); |
| 425 | extern uint64_t TIFFCurrentDirOffset(TIFF *); |
| 426 | extern uint32_t TIFFCurrentStrip(TIFF *); |
| 427 | extern uint32_t TIFFCurrentTile(TIFF *tif); |
| 428 | extern int TIFFReadBufferSetup(TIFF *tif, void *bp, tmsize_t size); |
| 429 | extern int TIFFWriteBufferSetup(TIFF *tif, void *bp, tmsize_t size); |
| 430 | extern int TIFFSetupStrips(TIFF *); |
| 431 | extern int TIFFWriteCheck(TIFF *, int, const char *); |
| 432 | extern void TIFFFreeDirectory(TIFF *); |
| 433 | extern int TIFFCreateDirectory(TIFF *); |
| 434 | extern int TIFFCreateCustomDirectory(TIFF *, const TIFFFieldArray *); |
| 435 | extern int TIFFCreateEXIFDirectory(TIFF *); |
| 436 | extern int TIFFCreateGPSDirectory(TIFF *); |
| 437 | extern int TIFFLastDirectory(TIFF *); |
| 438 | extern int TIFFSetDirectory(TIFF *, tdir_t); |
| 439 | extern int TIFFSetSubDirectory(TIFF *, uint64_t); |
| 440 | extern int TIFFUnlinkDirectory(TIFF *, tdir_t); |
| 441 | extern int TIFFSetField(TIFF *, uint32_t, ...); |
| 442 | extern int TIFFVSetField(TIFF *, uint32_t, va_list); |
| 443 | extern int TIFFUnsetField(TIFF *, uint32_t); |
| 444 | extern int TIFFWriteDirectory(TIFF *); |
| 445 | extern int TIFFWriteCustomDirectory(TIFF *, uint64_t *); |
| 446 | extern int TIFFCheckpointDirectory(TIFF *); |
| 447 | extern int TIFFRewriteDirectory(TIFF *); |
| 448 | extern int TIFFDeferStrileArrayWriting(TIFF *); |
| 449 | extern int TIFFForceStrileArrayWriting(TIFF *); |
| 450 | |
| 451 | #if defined(c_plusplus) || defined(__cplusplus) |
| 452 | extern void TIFFPrintDirectory(TIFF *, FILE *, long = 0); |
| 453 | extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row, |
| 454 | uint16_t sample = 0); |
| 455 | extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row, |
| 456 | uint16_t sample = 0); |
| 457 | extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *, |
| 458 | int = 0); |
| 459 | extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *, |
| 460 | int = ORIENTATION_BOTLEFT, int = 0); |
| 461 | #else |
| 462 | extern void TIFFPrintDirectory(TIFF *, FILE *, long); |
| 463 | extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row, |
| 464 | uint16_t sample); |
| 465 | extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row, |
| 466 | uint16_t sample); |
| 467 | extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *, int); |
| 468 | extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *, |
| 469 | int, int); |
| 470 | #endif |
| 471 | |
| 472 | extern int TIFFReadRGBAStrip(TIFF *, uint32_t, uint32_t *); |
| 473 | extern int TIFFReadRGBATile(TIFF *, uint32_t, uint32_t, uint32_t *); |
| 474 | extern int TIFFReadRGBAStripExt(TIFF *, uint32_t, uint32_t *, |
| 475 | int stop_on_error); |
| 476 | extern int TIFFReadRGBATileExt(TIFF *, uint32_t, uint32_t, uint32_t *, |
| 477 | int stop_on_error); |
| 478 | extern int TIFFRGBAImageOK(TIFF *, char[1024]); |
| 479 | extern int TIFFRGBAImageBegin(TIFFRGBAImage *, TIFF *, int, char[1024]); |
| 480 | extern int TIFFRGBAImageGet(TIFFRGBAImage *, uint32_t *, uint32_t, |
| 481 | uint32_t); |
| 482 | extern void TIFFRGBAImageEnd(TIFFRGBAImage *); |
| 483 | |
| 484 | extern const char *TIFFFileName(TIFF *); |
| 485 | extern const char *TIFFSetFileName(TIFF *, const char *); |
| 486 | extern void TIFFError(const char *, const char *, ...) |
| 487 | TIFF_ATTRIBUTE((__format__(__printf__, 2, 3))); |
| 488 | extern void TIFFErrorExt(thandle_t, const char *, const char *, ...) |
| 489 | TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); |
| 490 | extern void TIFFWarning(const char *, const char *, ...) |
| 491 | TIFF_ATTRIBUTE((__format__(__printf__, 2, 3))); |
| 492 | extern void TIFFWarningExt(thandle_t, const char *, const char *, ...) |
| 493 | TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); |
| 494 | extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); |
| 495 | extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); |
| 496 | extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); |
| 497 | extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); |
| 498 | |
| 499 | extern void TIFFWarningExtR(TIFF *, const char *, const char *, ...) |
| 500 | TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); |
| 501 | extern void TIFFErrorExtR(TIFF *, const char *, const char *, ...) |
| 502 | TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); |
| 503 | |
| 504 | typedef struct TIFFOpenOptions TIFFOpenOptions; |
| 505 | extern TIFFOpenOptions *TIFFOpenOptionsAlloc(void); |
| 506 | extern void TIFFOpenOptionsFree(TIFFOpenOptions *); |
| 507 | extern void |
| 508 | TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions *opts, |
| 509 | tmsize_t max_single_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_ */ |
| 654 | |