00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _TIFFIO_
00028 #define _TIFFIO_
00029
00030 #include "tiff_API.h"
00031
00032
00033
00034
00035 #include "tiff.h"
00036 #include "tiffvers.h"
00037
00038
00039
00040
00041
00042 typedef struct tiff TIFF;
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 typedef uint32 ttag_t;
00064 typedef uint16 tdir_t;
00065 typedef uint16 tsample_t;
00066 typedef uint32 tstrip_t;
00067 typedef uint32 ttile_t;
00068 typedef int32 tsize_t;
00069 typedef void* tdata_t;
00070 typedef uint32 toff_t;
00071
00072 #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
00073 #define __WIN32__
00074 #endif
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
00085 # if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILIO)
00086 # define USE_WIN32_FILEIO
00087 # endif
00088 #endif
00089
00090 #if defined(USE_WIN32_FILEIO)
00091 #include <windows.h>
00092 #ifdef __WIN32__
00093 DECLARE_HANDLE(thandle_t);
00094 #else
00095 typedef HFILE thandle_t;
00096 #endif
00097 #else
00098 typedef void* thandle_t;
00099 #endif
00100
00101 #ifndef NULL
00102 # define NULL (void *)0
00103 #endif
00104
00105
00106
00107
00108
00109
00110
00111 #define TIFFPRINT_NONE 0x0
00112 #define TIFFPRINT_STRIPS 0x1
00113 #define TIFFPRINT_CURVES 0x2
00114 #define TIFFPRINT_COLORMAP 0x4
00115 #define TIFFPRINT_JPEGQTABLES 0x100
00116 #define TIFFPRINT_JPEGACTABLES 0x200
00117 #define TIFFPRINT_JPEGDCTABLES 0x200
00118
00119
00120
00121
00122
00123
00124 #define D65_X0 (95.0470F)
00125 #define D65_Y0 (100.0F)
00126 #define D65_Z0 (108.8827F)
00127
00128 #define D50_X0 (96.4250F)
00129 #define D50_Y0 (100.0F)
00130 #define D50_Z0 (82.4680F)
00131
00132
00133
00134 typedef unsigned char TIFFRGBValue;
00135
00136 typedef struct {
00137 float d_mat[3][3];
00138 float d_YCR;
00139 float d_YCG;
00140 float d_YCB;
00141 uint32 d_Vrwr;
00142 uint32 d_Vrwg;
00143 uint32 d_Vrwb;
00144 float d_Y0R;
00145 float d_Y0G;
00146 float d_Y0B;
00147 float d_gammaR;
00148 float d_gammaG;
00149 float d_gammaB;
00150 } TIFFDisplay;
00151
00152 typedef struct {
00153 TIFFRGBValue* clamptab;
00154 int* Cr_r_tab;
00155 int* Cb_b_tab;
00156 int32* Cr_g_tab;
00157 int32* Cb_g_tab;
00158 int32* Y_tab;
00159 } TIFFYCbCrToRGB;
00160
00161 typedef struct {
00162 int range;
00163 #define CIELABTORGB_TABLE_RANGE 1500
00164 float rstep, gstep, bstep;
00165 float X0, Y0, Z0;
00166 TIFFDisplay display;
00167 float Yr2r[CIELABTORGB_TABLE_RANGE + 1];
00168 float Yg2g[CIELABTORGB_TABLE_RANGE + 1];
00169 float Yb2b[CIELABTORGB_TABLE_RANGE + 1];
00170 } TIFFCIELabToRGB;
00171
00172 tiff_API extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, TIFFDisplay *, float*);
00173 tiff_API extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32,
00174 float *, float *, float *);
00175 tiff_API extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float,
00176 uint32 *, uint32 *, uint32 *);
00177
00178 tiff_API extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*);
00179 tiff_API extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
00180 uint32 *, uint32 *, uint32 *);
00181
00182
00183
00184
00185 typedef struct _TIFFRGBAImage TIFFRGBAImage;
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 typedef void (*tileContigRoutine)
00197 (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
00198 unsigned char*);
00199 typedef void (*tileSeparateRoutine)
00200 (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
00201 unsigned char*, unsigned char*, unsigned char*, unsigned char*);
00202
00203
00204
00205 struct _TIFFRGBAImage {
00206 TIFF* tif;
00207 int stoponerr;
00208 int isContig;
00209 int alpha;
00210 uint32 width;
00211 uint32 height;
00212 uint16 bitspersample;
00213 uint16 samplesperpixel;
00214 uint16 orientation;
00215 uint16 req_orientation;
00216 uint16 photometric;
00217 uint16* redcmap;
00218 uint16* greencmap;
00219 uint16* bluecmap;
00220
00221 int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
00222 union {
00223 void (*any)(TIFFRGBAImage*);
00224 tileContigRoutine contig;
00225 tileSeparateRoutine separate;
00226 } put;
00227 TIFFRGBValue* Map;
00228 uint32** BWmap;
00229 uint32** PALmap;
00230 TIFFYCbCrToRGB* ycbcr;
00231 TIFFCIELabToRGB* cielab;
00232
00233 int row_offset;
00234 int col_offset;
00235 };
00236
00237
00238
00239
00240
00241 #define TIFFGetR(abgr) ((abgr) & 0xff)
00242 #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
00243 #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
00244 #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
00245
00246
00247
00248
00249
00250
00251
00252
00253 typedef int (*TIFFInitMethod)(TIFF*, int);
00254 typedef struct {
00255 char* name;
00256 uint16 scheme;
00257 TIFFInitMethod init;
00258 } TIFFCodec;
00259
00260 #include <stdio.h>
00261 #include <stdarg.h>
00262
00263
00264 #ifndef LOGLUV_PUBLIC
00265 #define LOGLUV_PUBLIC 1
00266 #endif
00267
00268 #if defined(__cplusplus)
00269 extern "C" {
00270 #endif
00271 typedef void (*TIFFErrorHandler)(const char*, const char*, va_list);
00272 typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);
00273 typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
00274 typedef int (*TIFFCloseProc)(thandle_t);
00275 typedef toff_t (*TIFFSizeProc)(thandle_t);
00276 typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);
00277 typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);
00278 typedef void (*TIFFExtendProc)(TIFF*);
00279
00280 tiff_API extern const char* TIFFGetVersion(void);
00281
00282 tiff_API extern const TIFFCodec* TIFFFindCODEC(uint16);
00283 tiff_API extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
00284 tiff_API extern void TIFFUnRegisterCODEC(TIFFCodec*);
00285 tiff_API extern int TIFFIsCODECConfigured(uint16);
00286 tiff_API extern TIFFCodec* TIFFGetConfiguredCODECs();
00287
00288 tiff_API extern tdata_t _TIFFmalloc(tsize_t);
00289 tiff_API extern tdata_t _TIFFrealloc(tdata_t, tsize_t);
00290 tiff_API extern void _TIFFmemset(tdata_t, int, tsize_t);
00291 tiff_API extern void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t);
00292 tiff_API extern int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t);
00293 tiff_API extern void _TIFFfree(tdata_t);
00294
00295 tiff_API extern void TIFFCleanup(TIFF*);
00296 tiff_API extern void TIFFClose(TIFF*);
00297 tiff_API extern int TIFFFlush(TIFF*);
00298 tiff_API extern int TIFFFlushData(TIFF*);
00299 tiff_API extern int TIFFGetField(TIFF*, ttag_t, ...);
00300 tiff_API extern int TIFFVGetField(TIFF*, ttag_t, va_list);
00301 tiff_API extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...);
00302 tiff_API extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list);
00303 tiff_API extern int TIFFReadDirectory(TIFF*);
00304 tiff_API extern tsize_t TIFFScanlineSize(TIFF*);
00305 tiff_API extern tsize_t TIFFRasterScanlineSize(TIFF*);
00306 tiff_API extern tsize_t TIFFStripSize(TIFF*);
00307 tiff_API extern tsize_t TIFFRawStripSize(TIFF*, tstrip_t);
00308 tiff_API extern tsize_t TIFFVStripSize(TIFF*, uint32);
00309 tiff_API extern tsize_t TIFFTileRowSize(TIFF*);
00310 tiff_API extern tsize_t TIFFTileSize(TIFF*);
00311 tiff_API extern tsize_t TIFFVTileSize(TIFF*, uint32);
00312 tiff_API extern uint32 TIFFDefaultStripSize(TIFF*, uint32);
00313 tiff_API extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
00314 tiff_API extern int TIFFFileno(TIFF*);
00315 tiff_API extern int TIFFSetFileno(TIFF*, int);
00316 tiff_API extern thandle_t TIFFClientdata(TIFF*);
00317 tiff_API extern thandle_t TIFFSetClientdata(TIFF*, thandle_t);
00318 tiff_API extern int TIFFGetMode(TIFF*);
00319 tiff_API extern int TIFFSetMode(TIFF*, int);
00320 tiff_API extern int TIFFIsTiled(TIFF*);
00321 tiff_API extern int TIFFIsByteSwapped(TIFF*);
00322 tiff_API extern int TIFFIsUpSampled(TIFF*);
00323 tiff_API extern int TIFFIsMSB2LSB(TIFF*);
00324 tiff_API extern int TIFFIsBigEndian(TIFF*);
00325 tiff_API extern TIFFReadWriteProc TIFFGetReadProc(TIFF*);
00326 tiff_API extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*);
00327 tiff_API extern TIFFSeekProc TIFFGetSeekProc(TIFF*);
00328 tiff_API extern TIFFCloseProc TIFFGetCloseProc(TIFF*);
00329 tiff_API extern TIFFSizeProc TIFFGetSizeProc(TIFF*);
00330 tiff_API extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*);
00331 tiff_API extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*);
00332 tiff_API extern uint32 TIFFCurrentRow(TIFF*);
00333 tiff_API extern tdir_t TIFFCurrentDirectory(TIFF*);
00334 tiff_API extern tdir_t TIFFNumberOfDirectories(TIFF*);
00335 tiff_API extern uint32 TIFFCurrentDirOffset(TIFF*);
00336 tiff_API extern tstrip_t TIFFCurrentStrip(TIFF*);
00337 tiff_API extern ttile_t TIFFCurrentTile(TIFF*);
00338 tiff_API extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t);
00339 tiff_API extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t);
00340 tiff_API extern int TIFFSetupStrips(TIFF *);
00341 tiff_API extern int TIFFWriteCheck(TIFF*, int, const char *);
00342 tiff_API extern int TIFFCreateDirectory(TIFF*);
00343 tiff_API extern int TIFFLastDirectory(TIFF*);
00344 tiff_API extern int TIFFSetDirectory(TIFF*, tdir_t);
00345 tiff_API extern int TIFFSetSubDirectory(TIFF*, uint32);
00346 tiff_API extern int TIFFUnlinkDirectory(TIFF*, tdir_t);
00347 tiff_API extern int TIFFSetField(TIFF*, ttag_t, ...);
00348 tiff_API extern int TIFFVSetField(TIFF*, ttag_t, va_list);
00349 tiff_API extern int TIFFWriteDirectory(TIFF *);
00350 tiff_API extern int TIFFCheckpointDirectory(TIFF *);
00351 tiff_API extern int TIFFRewriteDirectory(TIFF *);
00352 tiff_API extern int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int);
00353
00354 #if defined(c_plusplus) || defined(__cplusplus)
00355 tiff_API extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
00356 tiff_API extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
00357 tiff_API extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
00358 tiff_API extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
00359 tiff_API extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*,
00360 int = ORIENTATION_BOTLEFT, int = 0);
00361 #else
00362 tiff_API extern void TIFFPrintDirectory(TIFF*, FILE*, long);
00363 tiff_API extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t);
00364 tiff_API extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t);
00365 tiff_API extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
00366 tiff_API extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int);
00367 #endif
00368
00369 tiff_API extern int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * );
00370 tiff_API extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
00371 tiff_API extern int TIFFRGBAImageOK(TIFF*, char [1024]);
00372 tiff_API extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
00373 tiff_API extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
00374 tiff_API extern void TIFFRGBAImageEnd(TIFFRGBAImage*);
00375 tiff_API extern TIFF* TIFFOpen(const char*, const char*);
00376 tiff_API extern TIFF* TIFFFdOpen(int, const char*, const char*);
00377 tiff_API extern TIFF* TIFFClientOpen(const char*, const char*,
00378 thandle_t,
00379 TIFFReadWriteProc, TIFFReadWriteProc,
00380 TIFFSeekProc, TIFFCloseProc,
00381 TIFFSizeProc,
00382 TIFFMapFileProc, TIFFUnmapFileProc);
00383 tiff_API extern const char* TIFFFileName(TIFF*);
00384 tiff_API extern const char* TIFFSetFileName(TIFF*, const char *);
00385 tiff_API extern void TIFFError(const char*, const char*, ...);
00386 tiff_API extern void TIFFWarning(const char*, const char*, ...);
00387 tiff_API extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
00388 tiff_API extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
00389 tiff_API extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
00390 tiff_API extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t);
00391 tiff_API extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t);
00392 tiff_API extern ttile_t TIFFNumberOfTiles(TIFF*);
00393 tiff_API extern tsize_t TIFFReadTile(TIFF*,
00394 tdata_t, uint32, uint32, uint32, tsample_t);
00395 tiff_API extern tsize_t TIFFWriteTile(TIFF*,
00396 tdata_t, uint32, uint32, uint32, tsample_t);
00397 tiff_API extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t);
00398 tiff_API extern tstrip_t TIFFNumberOfStrips(TIFF*);
00399 tiff_API extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
00400 tiff_API extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
00401 tiff_API extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
00402 tiff_API extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
00403 tiff_API extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
00404 tiff_API extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
00405 tiff_API extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
00406 tiff_API extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
00407 tiff_API extern int TIFFDataWidth(TIFFDataType);
00408 tiff_API extern void TIFFSetWriteOffset(TIFF*, toff_t);
00409 tiff_API extern void TIFFSwabShort(uint16*);
00410 tiff_API extern void TIFFSwabLong(uint32*);
00411 tiff_API extern void TIFFSwabDouble(double*);
00412 tiff_API extern void TIFFSwabArrayOfShort(uint16*, unsigned long);
00413 tiff_API extern void TIFFSwabArrayOfLong(uint32*, unsigned long);
00414 tiff_API extern void TIFFSwabArrayOfDouble(double*, unsigned long);
00415 tiff_API extern void TIFFReverseBits(unsigned char *, unsigned long);
00416 tiff_API extern const unsigned char* TIFFGetBitRevTable(int);
00417
00418 #ifdef LOGLUV_PUBLIC
00419 #define U_NEU 0.210526316
00420 #define V_NEU 0.473684211
00421 #define UVSCALE 410.
00422 tiff_API extern double LogL16toY(int);
00423 tiff_API extern double LogL10toY(int);
00424 tiff_API extern void XYZtoRGB24(float*, uint8*);
00425 tiff_API extern int uv_decode(double*, double*, int);
00426 tiff_API extern void LogLuv24toXYZ(uint32, float*);
00427 tiff_API extern void LogLuv32toXYZ(uint32, float*);
00428 #if defined(c_plusplus) || defined(__cplusplus)
00429 tiff_API extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
00430 tiff_API extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
00431 tiff_API extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
00432 tiff_API extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER);
00433 tiff_API extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER);
00434 #else
00435 tiff_API extern int LogL16fromY(double, int);
00436 tiff_API extern int LogL10fromY(double, int);
00437 tiff_API extern int uv_encode(double, double, int);
00438 tiff_API extern uint32 LogLuv24fromXYZ(float*, int);
00439 tiff_API extern uint32 LogLuv32fromXYZ(float*, int);
00440 #endif
00441 #endif
00442
00443
00444
00445
00446 tiff_API extern int TIFFGetTagListCount( TIFF * );
00447 tiff_API extern ttag_t TIFFGetTagListEntry( TIFF *, int tag_index );
00448
00449 #define TIFF_ANY TIFF_NOTYPE
00450 #define TIFF_VARIABLE -1
00451 #define TIFF_SPP -2
00452 #define TIFF_VARIABLE2 -3
00453
00454 #define FIELD_CUSTOM 65
00455
00456 typedef struct {
00457 ttag_t field_tag;
00458 short field_readcount;
00459 short field_writecount;
00460 TIFFDataType field_type;
00461 unsigned short field_bit;
00462 unsigned char field_oktochange;
00463 unsigned char field_passcount;
00464 char *field_name;
00465 } TIFFFieldInfo;
00466
00467 typedef struct _TIFFTagValue {
00468 const TIFFFieldInfo *info;
00469 int count;
00470 void *value;
00471 } TIFFTagValue;
00472
00473 tiff_API extern void TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int);
00474 tiff_API extern const TIFFFieldInfo* TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType);
00475 tiff_API extern const TIFFFieldInfo* TIFFFindFieldInfoByName(TIFF* , const char *,
00476 TIFFDataType);
00477 tiff_API extern const TIFFFieldInfo* TIFFFieldWithTag(TIFF*, ttag_t);
00478 tiff_API extern const TIFFFieldInfo* TIFFFieldWithName(TIFF*, const char *);
00479
00480 typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list);
00481 typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list);
00482 typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long);
00483
00484 typedef struct {
00485 TIFFVSetMethod vsetfield;
00486 TIFFVGetMethod vgetfield;
00487 TIFFPrintMethod printdir;
00488 } TIFFTagMethods;
00489
00490 tiff_API extern TIFFTagMethods *TIFFAccessTagMethods( TIFF * );
00491 tiff_API extern void *TIFFGetClientInfo( TIFF *, const char * );
00492 tiff_API extern void TIFFSetClientInfo( TIFF *, void *, const char * );
00493
00494 #if defined(__cplusplus)
00495 }
00496 #endif
00497
00498 #if defined(c_plusplus) || defined(__cplusplus)
00499 #include <iostream.h>
00500 tiff_API extern TIFF* TIFFStreamOpen(const char*, ostream *);
00501 tiff_API extern TIFF* TIFFStreamOpen(const char*, istream *);
00502 #endif
00503
00504 #endif
00505
00506