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 uint16_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) && !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 float d_mat[3][3]; /* XYZ -> luminance matrix */ 142 float d_YCR; /* Light o/p for reference white */ 143 float d_YCG; 144 float d_YCB; 145 uint32_t d_Vrwr; /* Pixel values for ref. white */ 146 uint32_t d_Vrwg; 147 uint32_t d_Vrwb; 148 float d_Y0R; /* Residual light for black pixel */ 149 float d_Y0G; 150 float d_Y0B; 151 float d_gammaR; /* Gamma values for the three guns */ 152 float d_gammaG; 153 float d_gammaB; 154 } TIFFDisplay; 155 156 typedef struct { /* YCbCr->RGB support */ 157 TIFFRGBValue* clamptab; /* range clamping table */ 158 int* Cr_r_tab; 159 int* Cb_b_tab; 160 int32_t* Cr_g_tab; 161 int32_t* Cb_g_tab; 162 int32_t* Y_tab; 163 } TIFFYCbCrToRGB; 164 165 typedef struct { /* 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) 191 (TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, int32_t, 192 unsigned char*); 193 typedef void (*tileSeparateRoutine) 194 (TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, int32_t, 195 unsigned char*, unsigned char*, unsigned char*, unsigned char*); 196 /* 197 * RGBA-reader state. 198 */ 199 struct _TIFFRGBAImage { 200 TIFF* tif; /* image handle */ 201 int stoponerr; /* stop on read error */ 202 int isContig; /* data is packed/separate */ 203 int alpha; /* type of alpha data present */ 204 uint32_t width; /* image width */ 205 uint32_t height; /* image height */ 206 uint16_t bitspersample; /* image bits/sample */ 207 uint16_t samplesperpixel; /* image samples/pixel */ 208 uint16_t orientation; /* image orientation */ 209 uint16_t req_orientation; /* requested orientation */ 210 uint16_t photometric; /* image photometric interp */ 211 uint16_t* redcmap; /* colormap palette */ 212 uint16_t* greencmap; 213 uint16_t* bluecmap; 214 /* get image data routine */ 215 int (*get)(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); 216 /* put decoded strip/tile */ 217 union { 218 void (*any)(TIFFRGBAImage*); 219 tileContigRoutine contig; 220 tileSeparateRoutine separate; 221 } put; 222 TIFFRGBValue* Map; /* sample mapping array */ 223 uint32_t** BWmap; /* black&white map */ 224 uint32_t** PALmap; /* palette image map */ 225 TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ 226 TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ 227 228 uint8_t* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ 229 uint8_t* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ 230 231 int row_offset; 232 int col_offset; 233 }; 234 235 /* 236 * Macros for extracting components from the 237 * packed ABGR form returned by TIFFReadRGBAImage. 238 */ 239 #define TIFFGetR(abgr) ((abgr) & 0xff) 240 #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) 241 #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) 242 #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) 243 244 /* 245 * A CODEC is a software package that implements decoding, 246 * encoding, or decoding+encoding of a compression algorithm. 247 * The library provides a collection of builtin codecs. 248 * More codecs may be registered through calls to the library 249 * and/or the builtin implementations may be overridden. 250 */ 251 typedef int (*TIFFInitMethod)(TIFF*, int); 252 typedef struct { 253 char* name; 254 uint16_t scheme; 255 TIFFInitMethod init; 256 } TIFFCodec; 257 258 #include <stdio.h> 259 #include <stdarg.h> 260 261 /* share internal LogLuv conversion routines? */ 262 #ifndef LOGLUV_PUBLIC 263 #define LOGLUV_PUBLIC 1 264 #endif 265 266 #if defined(__GNUC__) || defined(__attribute__) 267 # define TIFF_ATTRIBUTE(x) __attribute__(x) 268 #else 269 # define TIFF_ATTRIBUTE(x) /*nothing*/ 270 #endif 271 272 #if defined(c_plusplus) || defined(__cplusplus) 273 extern "C" { 274 #endif 275 typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); 276 typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); 277 typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); 278 typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); 279 typedef int (*TIFFCloseProc)(thandle_t); 280 typedef toff_t (*TIFFSizeProc)(thandle_t); 281 typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); 282 typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); 283 typedef void (*TIFFExtendProc)(TIFF*); 284 285 extern const char* TIFFGetVersion(void); 286 287 extern const TIFFCodec* TIFFFindCODEC(uint16_t); 288 extern TIFFCodec* TIFFRegisterCODEC(uint16_t, const char*, TIFFInitMethod); 289 extern void TIFFUnRegisterCODEC(TIFFCodec*); 290 extern int TIFFIsCODECConfigured(uint16_t); 291 extern TIFFCodec* TIFFGetConfiguredCODECs(void); 292 293 /* 294 * Auxiliary functions. 295 */ 296 297 extern void* _TIFFmalloc(tmsize_t s); 298 extern void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz); 299 extern void* _TIFFrealloc(void* p, tmsize_t s); 300 extern void _TIFFmemset(void* p, int v, tmsize_t c); 301 extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); 302 extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); 303 extern void _TIFFfree(void* p); 304 305 /* 306 ** Stuff, related to tag handling and creating custom tags. 307 */ 308 extern int TIFFGetTagListCount( TIFF * ); 309 extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index ); 310 311 #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ 312 #define TIFF_VARIABLE -1 /* marker for variable length tags */ 313 #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ 314 #define TIFF_VARIABLE2 -3 /* marker for uint32_t var-length tags */ 315 316 #define FIELD_CUSTOM 65 317 318 typedef struct _TIFFField TIFFField; 319 typedef struct _TIFFFieldArray TIFFFieldArray; 320 321 extern const TIFFField* TIFFFindField(TIFF *, uint32_t, TIFFDataType); 322 extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32_t); 323 extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); 324 325 extern uint32_t TIFFFieldTag(const TIFFField*); 326 extern const char* TIFFFieldName(const TIFFField*); 327 extern TIFFDataType TIFFFieldDataType(const TIFFField*); 328 extern int TIFFFieldPassCount(const TIFFField*); 329 extern int TIFFFieldReadCount(const TIFFField*); 330 extern int TIFFFieldWriteCount(const TIFFField*); 331 332 typedef int (*TIFFVSetMethod)(TIFF*, uint32_t, va_list); 333 typedef int (*TIFFVGetMethod)(TIFF*, uint32_t, va_list); 334 typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); 335 336 typedef struct { 337 TIFFVSetMethod vsetfield; /* tag set routine */ 338 TIFFVGetMethod vgetfield; /* tag get routine */ 339 TIFFPrintMethod printdir; /* directory print routine */ 340 } TIFFTagMethods; 341 342 extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); 343 extern void *TIFFGetClientInfo(TIFF *, const char *); 344 extern void TIFFSetClientInfo(TIFF *, void *, const char *); 345 346 extern void TIFFCleanup(TIFF* tif); 347 extern void TIFFClose(TIFF* tif); 348 extern int TIFFFlush(TIFF* tif); 349 extern int TIFFFlushData(TIFF* tif); 350 extern int TIFFGetField(TIFF* tif, uint32_t tag, ...); 351 extern int TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap); 352 extern int TIFFGetFieldDefaulted(TIFF* tif, uint32_t tag, ...); 353 extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32_t tag, va_list ap); 354 extern int TIFFReadDirectory(TIFF* tif); 355 extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); 356 extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); 357 extern int TIFFReadGPSDirectory(TIFF* tif, toff_t diroff); 358 extern uint64_t TIFFScanlineSize64(TIFF* tif); 359 extern tmsize_t TIFFScanlineSize(TIFF* tif); 360 extern uint64_t TIFFRasterScanlineSize64(TIFF* tif); 361 extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); 362 extern uint64_t TIFFStripSize64(TIFF* tif); 363 extern tmsize_t TIFFStripSize(TIFF* tif); 364 extern uint64_t TIFFRawStripSize64(TIFF* tif, uint32_t strip); 365 extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32_t strip); 366 extern uint64_t TIFFVStripSize64(TIFF* tif, uint32_t nrows); 367 extern tmsize_t TIFFVStripSize(TIFF* tif, uint32_t nrows); 368 extern uint64_t TIFFTileRowSize64(TIFF* tif); 369 extern tmsize_t TIFFTileRowSize(TIFF* tif); 370 extern uint64_t TIFFTileSize64(TIFF* tif); 371 extern tmsize_t TIFFTileSize(TIFF* tif); 372 extern uint64_t TIFFVTileSize64(TIFF* tif, uint32_t nrows); 373 extern tmsize_t TIFFVTileSize(TIFF* tif, uint32_t nrows); 374 extern uint32_t TIFFDefaultStripSize(TIFF* tif, uint32_t request); 375 extern void TIFFDefaultTileSize(TIFF*, uint32_t*, uint32_t*); 376 extern int TIFFFileno(TIFF*); 377 extern int TIFFSetFileno(TIFF*, int); 378 extern thandle_t TIFFClientdata(TIFF*); 379 extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); 380 extern int TIFFGetMode(TIFF*); 381 extern int TIFFSetMode(TIFF*, int); 382 extern int TIFFIsTiled(TIFF*); 383 extern int TIFFIsByteSwapped(TIFF*); 384 extern int TIFFIsUpSampled(TIFF*); 385 extern int TIFFIsMSB2LSB(TIFF*); 386 extern int TIFFIsBigEndian(TIFF*); 387 extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); 388 extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); 389 extern TIFFSeekProc TIFFGetSeekProc(TIFF*); 390 extern TIFFCloseProc TIFFGetCloseProc(TIFF*); 391 extern TIFFSizeProc TIFFGetSizeProc(TIFF*); 392 extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); 393 extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); 394 extern uint32_t TIFFCurrentRow(TIFF*); 395 extern uint16_t TIFFCurrentDirectory(TIFF*); 396 extern uint16_t TIFFNumberOfDirectories(TIFF*); 397 extern uint64_t TIFFCurrentDirOffset(TIFF*); 398 extern uint32_t TIFFCurrentStrip(TIFF*); 399 extern uint32_t TIFFCurrentTile(TIFF* tif); 400 extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); 401 extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); 402 extern int TIFFSetupStrips(TIFF *); 403 extern int TIFFWriteCheck(TIFF*, int, const char *); 404 extern void TIFFFreeDirectory(TIFF*); 405 extern int TIFFCreateDirectory(TIFF*); 406 extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); 407 extern int TIFFCreateEXIFDirectory(TIFF*); 408 extern int TIFFCreateGPSDirectory(TIFF*); 409 extern int TIFFLastDirectory(TIFF*); 410 extern int TIFFSetDirectory(TIFF*, uint16_t); 411 extern int TIFFSetSubDirectory(TIFF*, uint64_t); 412 extern int TIFFUnlinkDirectory(TIFF*, uint16_t); 413 extern int TIFFSetField(TIFF*, uint32_t, ...); 414 extern int TIFFVSetField(TIFF*, uint32_t, va_list); 415 extern int TIFFUnsetField(TIFF*, uint32_t); 416 extern int TIFFWriteDirectory(TIFF *); 417 extern int TIFFWriteCustomDirectory(TIFF *, uint64_t *); 418 extern int TIFFCheckpointDirectory(TIFF *); 419 extern int TIFFRewriteDirectory(TIFF *); 420 extern int TIFFDeferStrileArrayWriting(TIFF *); 421 extern int TIFFForceStrileArrayWriting(TIFF* ); 422 423 #if defined(c_plusplus) || defined(__cplusplus) 424 extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); 425 extern int TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample = 0); 426 extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample = 0); 427 extern int TIFFReadRGBAImage(TIFF*, uint32_t, uint32_t, uint32_t*, int = 0); 428 extern int TIFFReadRGBAImageOriented(TIFF*, uint32_t, uint32_t, uint32_t*, 429 int = ORIENTATION_BOTLEFT, int = 0); 430 #else 431 extern void TIFFPrintDirectory(TIFF*, FILE*, long); 432 extern int TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample); 433 extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample); 434 extern int TIFFReadRGBAImage(TIFF*, uint32_t, uint32_t, uint32_t*, int); 435 extern int TIFFReadRGBAImageOriented(TIFF*, uint32_t, uint32_t, uint32_t*, int, int); 436 #endif 437 438 extern int TIFFReadRGBAStrip(TIFF*, uint32_t, uint32_t * ); 439 extern int TIFFReadRGBATile(TIFF*, uint32_t, uint32_t, uint32_t * ); 440 extern int TIFFReadRGBAStripExt(TIFF*, uint32_t, uint32_t *, int stop_on_error ); 441 extern int TIFFReadRGBATileExt(TIFF*, uint32_t, uint32_t, uint32_t *, int stop_on_error ); 442 extern int TIFFRGBAImageOK(TIFF*, char [1024]); 443 extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); 444 extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); 445 extern void TIFFRGBAImageEnd(TIFFRGBAImage*); 446 extern TIFF* TIFFOpen(const char*, const char*); 447 # ifdef __WIN32__ 448 extern TIFF* TIFFOpenW(const wchar_t*, const char*); 449 # endif /* __WIN32__ */ 450 extern TIFF* TIFFFdOpen(int, const char*, const char*); 451 extern TIFF* TIFFClientOpen(const char*, const char*, 452 thandle_t, 453 TIFFReadWriteProc, TIFFReadWriteProc, 454 TIFFSeekProc, TIFFCloseProc, 455 TIFFSizeProc, 456 TIFFMapFileProc, TIFFUnmapFileProc); 457 extern const char* TIFFFileName(TIFF*); 458 extern const char* TIFFSetFileName(TIFF*, const char *); 459 extern void TIFFError(const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,2,3))); 460 extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4))); 461 extern void TIFFWarning(const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,2,3))); 462 extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4))); 463 extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); 464 extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); 465 extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); 466 extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); 467 extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); 468 extern uint32_t TIFFComputeTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s); 469 extern int TIFFCheckTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s); 470 extern uint32_t TIFFNumberOfTiles(TIFF*); 471 extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s); 472 extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s); 473 extern uint32_t TIFFComputeStrip(TIFF*, uint32_t, uint16_t); 474 extern uint32_t TIFFNumberOfStrips(TIFF*); 475 extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size); 476 extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size); 477 extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size); 478 extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size); 479 extern int TIFFReadFromUserBuffer(TIFF* tif, uint32_t strile, 480 void* inbuf, tmsize_t insize, 481 void* outbuf, tmsize_t outsize); 482 extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc); 483 extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc); 484 extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc); 485 extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc); 486 extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ 487 extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); 488 extern void TIFFSwabShort(uint16_t*); 489 extern void TIFFSwabLong(uint32_t*); 490 extern void TIFFSwabLong8(uint64_t*); 491 extern void TIFFSwabFloat(float*); 492 extern void TIFFSwabDouble(double*); 493 extern void TIFFSwabArrayOfShort(uint16_t* wp, tmsize_t n); 494 extern void TIFFSwabArrayOfTriples(uint8_t* tp, tmsize_t n); 495 extern void TIFFSwabArrayOfLong(uint32_t* lp, tmsize_t n); 496 extern void TIFFSwabArrayOfLong8(uint64_t* lp, tmsize_t n); 497 extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); 498 extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); 499 extern void TIFFReverseBits(uint8_t* cp, tmsize_t n); 500 extern const unsigned char* TIFFGetBitRevTable(int); 501 502 extern uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile); 503 extern uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile); 504 extern uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile, int *pbErr); 505 extern uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile, int *pbErr); 506 507 #ifdef LOGLUV_PUBLIC 508 #define U_NEU 0.210526316 509 #define V_NEU 0.473684211 510 #define UVSCALE 410. 511 extern double LogL16toY(int); 512 extern double LogL10toY(int); 513 extern void XYZtoRGB24(float*, uint8_t*); 514 extern int uv_decode(double*, double*, int); 515 extern void LogLuv24toXYZ(uint32_t, float*); 516 extern void LogLuv32toXYZ(uint32_t, float*); 517 #if defined(c_plusplus) || defined(__cplusplus) 518 extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); 519 extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); 520 extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); 521 extern uint32_t LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); 522 extern uint32_t LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); 523 #else 524 extern int LogL16fromY(double, int); 525 extern int LogL10fromY(double, int); 526 extern int uv_encode(double, double, int); 527 extern uint32_t LogLuv24fromXYZ(float*, int); 528 extern uint32_t LogLuv32fromXYZ(float*, int); 529 #endif 530 #endif /* LOGLUV_PUBLIC */ 531 532 extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); 533 extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t, 534 float *, float *, float *); 535 extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, 536 uint32_t *, uint32_t *, uint32_t *); 537 538 extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); 539 extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t, 540 uint32_t *, uint32_t *, uint32_t *); 541 542 /**************************************************************************** 543 * O B S O L E T E D I N T E R F A C E S 544 * 545 * Don't use this stuff in your applications, it may be removed in the future 546 * libtiff versions. 547 ****************************************************************************/ 548 typedef struct { 549 ttag_t field_tag; /* field's tag */ 550 short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ 551 short field_writecount; /* write count/TIFF_VARIABLE */ 552 TIFFDataType field_type; /* type of associated data */ 553 unsigned short field_bit; /* bit in fieldsset bit vector */ 554 unsigned char field_oktochange; /* if true, can change while writing */ 555 unsigned char field_passcount; /* if true, pass dir count on set */ 556 char *field_name; /* ASCII name */ 557 } TIFFFieldInfo; 558 559 extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32_t); 560 561 #if defined(c_plusplus) || defined(__cplusplus) 562 } 563 #endif 564 565 #endif /* _TIFFIO_ */ 566 567 /* vim: set ts=8 sts=8 sw=8 noet: */ 568 /* 569 * Local Variables: 570 * mode: c 571 * c-basic-offset: 8 572 * fill-column: 78 573 * End: 574 */ 575