Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-05-18 08:30:24

0001 /*
0002  * Copyright (c) 1988-1997 Sam Leffler
0003  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
0004  *
0005  * Permission to use, copy, modify, distribute, and sell this software and
0006  * its documentation for any purpose is hereby granted without fee, provided
0007  * that (i) the above copyright notices and this permission notice appear in
0008  * all copies of the software and related documentation, and (ii) the names of
0009  * Sam Leffler and Silicon Graphics may not be used in any advertising or
0010  * publicity relating to the software without the specific, prior written
0011  * permission of Sam Leffler and Silicon Graphics.
0012  *
0013  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
0014  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
0015  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
0016  *
0017  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
0018  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
0019  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
0020  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
0021  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
0022  * OF THIS SOFTWARE.
0023  */
0024 
0025 #ifndef _TIFFIO_
0026 #define _TIFFIO_
0027 
0028 /*
0029  * TIFF I/O Library Definitions.
0030  */
0031 #include "tiff.h"
0032 #include "tiffvers.h"
0033 
0034 /*
0035  * TIFF is defined as an incomplete type to hide the
0036  * library's internal data structures from clients.
0037  */
0038 typedef struct tiff TIFF;
0039 
0040 /*
0041  * The following typedefs define the intrinsic size of
0042  * data types used in the *exported* interfaces.  These
0043  * definitions depend on the proper definition of types
0044  * in tiff.h.  Note also that the varargs interface used
0045  * to pass tag types and values uses the types defined in
0046  * tiff.h directly.
0047  *
0048  * NB: ttag_t is unsigned int and not unsigned short because
0049  *     ANSI C requires that the type before the ellipsis be a
0050  *     promoted type (i.e. one of int, unsigned int, pointer,
0051  *     or double) and because we defined pseudo-tags that are
0052  *     outside the range of legal Aldus-assigned tags.
0053  * NB: tsize_t is signed and not unsigned because some functions
0054  *     return -1.
0055  * NB: toff_t is not off_t for many reasons; TIFFs max out at
0056  *     32-bit file offsets, and BigTIFF maxes out at 64-bit
0057  *     offsets being the most important, and to ensure use of
0058  *     a consistently unsigned type across architectures.
0059  *     Prior to libtiff 4.0, this was an unsigned 32 bit type.
0060  */
0061 /*
0062  * this is the machine addressing size type, only it's signed, so make it
0063  * int32_t on 32bit machines, int64_t on 64bit machines
0064  */
0065 typedef TIFF_SSIZE_T tmsize_t;
0066 #define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1)
0067 
0068 typedef uint64_t toff_t; /* file offset */
0069 /* the following are deprecated and should be replaced by their defining
0070    counterparts */
0071 typedef uint32_t ttag_t;    /* directory tag */
0072 typedef uint32_t tdir_t;    /* directory index */
0073 typedef uint16_t tsample_t; /* sample number */
0074 typedef uint32_t tstrile_t; /* strip or tile number */
0075 typedef tstrile_t tstrip_t; /* strip number */
0076 typedef tstrile_t ttile_t;  /* tile number */
0077 typedef tmsize_t tsize_t;   /* i/o size in bytes */
0078 typedef void *tdata_t;      /* image data ref */
0079 
0080 #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
0081 #define __WIN32__
0082 #endif
0083 
0084 /*
0085  * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c
0086  * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c).
0087  *
0088  * By default tif_unix.c is assumed.
0089  */
0090 
0091 #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
0092 #if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) &&                      \
0093     !defined(USE_WIN32_FILEIO)
0094 #define AVOID_WIN32_FILEIO
0095 #endif
0096 #endif
0097 
0098 #if defined(USE_WIN32_FILEIO)
0099 #define VC_EXTRALEAN
0100 #include <windows.h>
0101 #ifdef __WIN32__
0102 DECLARE_HANDLE(thandle_t); /* Win32 file handle */
0103 #else
0104 typedef HFILE thandle_t; /* client data handle */
0105 #endif /* __WIN32__ */
0106 #else
0107 typedef void *thandle_t; /* client data handle */
0108 #endif /* USE_WIN32_FILEIO */
0109 
0110 /*
0111  * Flags to pass to TIFFPrintDirectory to control
0112  * printing of data structures that are potentially
0113  * very large.   Bit-or these flags to enable printing
0114  * multiple items.
0115  */
0116 #define TIFFPRINT_NONE 0x0           /* no extra info */
0117 #define TIFFPRINT_STRIPS 0x1         /* strips/tiles info */
0118 #define TIFFPRINT_CURVES 0x2         /* color/gray response curves */
0119 #define TIFFPRINT_COLORMAP 0x4       /* colormap */
0120 #define TIFFPRINT_JPEGQTABLES 0x100  /* JPEG Q matrices */
0121 #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */
0122 #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */
0123 
0124 /*
0125  * Colour conversion stuff
0126  */
0127 
0128 /* reference white */
0129 #define D65_X0 (95.0470F)
0130 #define D65_Y0 (100.0F)
0131 #define D65_Z0 (108.8827F)
0132 
0133 #define D50_X0 (96.4250F)
0134 #define D50_Y0 (100.0F)
0135 #define D50_Z0 (82.4680F)
0136 
0137 /* Structure for holding information about a display device. */
0138 
0139 typedef unsigned char TIFFRGBValue; /* 8-bit samples */
0140 
0141 typedef struct
0142 {
0143     float d_mat[3][3]; /* XYZ -> luminance matrix */
0144     float d_YCR;       /* Light o/p for reference white */
0145     float d_YCG;
0146     float d_YCB;
0147     uint32_t d_Vrwr; /* Pixel values for ref. white */
0148     uint32_t d_Vrwg;
0149     uint32_t d_Vrwb;
0150     float d_Y0R; /* Residual light for black pixel */
0151     float d_Y0G;
0152     float d_Y0B;
0153     float d_gammaR; /* Gamma values for the three guns */
0154     float d_gammaG;
0155     float d_gammaB;
0156 } TIFFDisplay;
0157 
0158 typedef struct
0159 {                           /* YCbCr->RGB support */
0160     TIFFRGBValue *clamptab; /* range clamping table */
0161     int *Cr_r_tab;
0162     int *Cb_b_tab;
0163     int32_t *Cr_g_tab;
0164     int32_t *Cb_g_tab;
0165     int32_t *Y_tab;
0166 } TIFFYCbCrToRGB;
0167 
0168 typedef struct
0169 {              /* CIE Lab 1976->RGB support */
0170     int range; /* Size of conversion table */
0171 #define CIELABTORGB_TABLE_RANGE 1500
0172     float rstep, gstep, bstep;
0173     float X0, Y0, Z0; /* Reference white point */
0174     TIFFDisplay display;
0175     float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
0176     float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
0177     float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
0178 } TIFFCIELabToRGB;
0179 
0180 /*
0181  * RGBA-style image support.
0182  */
0183 typedef struct _TIFFRGBAImage TIFFRGBAImage;
0184 /*
0185  * The image reading and conversion routines invoke
0186  * ``put routines'' to copy/image/whatever tiles of
0187  * raw image data.  A default set of routines are
0188  * provided to convert/copy raw image data to 8-bit
0189  * packed ABGR format rasters.  Applications can supply
0190  * alternate routines that unpack the data into a
0191  * different format or, for example, unpack the data
0192  * and draw the unpacked raster on the display.
0193  */
0194 typedef void (*tileContigRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t,
0195                                   uint32_t, uint32_t, uint32_t, int32_t,
0196                                   int32_t, unsigned char *);
0197 typedef void (*tileSeparateRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t,
0198                                     uint32_t, uint32_t, uint32_t, int32_t,
0199                                     int32_t, unsigned char *, unsigned char *,
0200                                     unsigned char *, unsigned char *);
0201 /*
0202  * RGBA-reader state.
0203  */
0204 struct _TIFFRGBAImage
0205 {
0206     TIFF *tif;                /* image handle */
0207     int stoponerr;            /* stop on read error */
0208     int isContig;             /* data is packed/separate */
0209     int alpha;                /* type of alpha data present */
0210     uint32_t width;           /* image width */
0211     uint32_t height;          /* image height */
0212     uint16_t bitspersample;   /* image bits/sample */
0213     uint16_t samplesperpixel; /* image samples/pixel */
0214     uint16_t orientation;     /* image orientation */
0215     uint16_t req_orientation; /* requested orientation */
0216     uint16_t photometric;     /* image photometric interp */
0217     uint16_t *redcmap;        /* colormap palette */
0218     uint16_t *greencmap;
0219     uint16_t *bluecmap;
0220     /* get image data routine */
0221     int (*get)(TIFFRGBAImage *, uint32_t *, uint32_t, uint32_t);
0222     /* put decoded strip/tile */
0223     union
0224     {
0225         void (*any)(TIFFRGBAImage *);
0226         tileContigRoutine contig;
0227         tileSeparateRoutine separate;
0228     } put;
0229     TIFFRGBValue *Map;       /* sample mapping array */
0230     uint32_t **BWmap;        /* black&white map */
0231     uint32_t **PALmap;       /* palette image map */
0232     TIFFYCbCrToRGB *ycbcr;   /* YCbCr conversion state */
0233     TIFFCIELabToRGB *cielab; /* CIE L*a*b conversion state */
0234 
0235     uint8_t *UaToAa; /* Unassociated alpha to associated alpha conversion LUT */
0236     uint8_t *Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
0237 
0238     int row_offset;
0239     int col_offset;
0240 };
0241 
0242 /*
0243  * Macros for extracting components from the
0244  * packed ABGR form returned by TIFFReadRGBAImage.
0245  */
0246 #define TIFFGetR(abgr) ((abgr)&0xff)
0247 #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
0248 #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
0249 #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
0250 
0251 /*
0252  * A CODEC is a software package that implements decoding,
0253  * encoding, or decoding+encoding of a compression algorithm.
0254  * The library provides a collection of builtin codecs.
0255  * More codecs may be registered through calls to the library
0256  * and/or the builtin implementations may be overridden.
0257  */
0258 typedef int (*TIFFInitMethod)(TIFF *, int);
0259 typedef struct
0260 {
0261     char *name;
0262     uint16_t scheme;
0263     TIFFInitMethod init;
0264 } TIFFCodec;
0265 
0266 typedef struct
0267 {
0268     uint32_t uNum;
0269     uint32_t uDenom;
0270 } TIFFRational_t;
0271 
0272 #include <stdarg.h>
0273 #include <stdio.h>
0274 
0275 /* share internal LogLuv conversion routines? */
0276 #ifndef LOGLUV_PUBLIC
0277 #define LOGLUV_PUBLIC 1
0278 #endif
0279 
0280 #if defined(__GNUC__) || defined(__attribute__)
0281 #define TIFF_ATTRIBUTE(x) __attribute__(x)
0282 #else
0283 #define TIFF_ATTRIBUTE(x) /*nothing*/
0284 #endif
0285 
0286 #if defined(c_plusplus) || defined(__cplusplus)
0287 extern "C"
0288 {
0289 #endif
0290     typedef void (*TIFFErrorHandler)(const char *, const char *, va_list);
0291     typedef void (*TIFFErrorHandlerExt)(thandle_t, const char *, const char *,
0292                                         va_list);
0293     typedef int (*TIFFErrorHandlerExtR)(TIFF *, void *user_data, const char *,
0294                                         const char *, va_list);
0295     typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void *, tmsize_t);
0296     typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
0297     typedef int (*TIFFCloseProc)(thandle_t);
0298     typedef toff_t (*TIFFSizeProc)(thandle_t);
0299     typedef int (*TIFFMapFileProc)(thandle_t, void **base, toff_t *size);
0300     typedef void (*TIFFUnmapFileProc)(thandle_t, void *base, toff_t size);
0301     typedef void (*TIFFExtendProc)(TIFF *);
0302 
0303     extern const char *TIFFGetVersion(void);
0304 
0305     extern const TIFFCodec *TIFFFindCODEC(uint16_t);
0306     extern TIFFCodec *TIFFRegisterCODEC(uint16_t, const char *, TIFFInitMethod);
0307     extern void TIFFUnRegisterCODEC(TIFFCodec *);
0308     extern int TIFFIsCODECConfigured(uint16_t);
0309     extern TIFFCodec *TIFFGetConfiguredCODECs(void);
0310 
0311     /*
0312      * Auxiliary functions.
0313      */
0314 
0315     extern void *_TIFFmalloc(tmsize_t s);
0316     extern void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz);
0317     extern void *_TIFFrealloc(void *p, tmsize_t s);
0318     extern void _TIFFmemset(void *p, int v, tmsize_t c);
0319     extern void _TIFFmemcpy(void *d, const void *s, tmsize_t c);
0320     extern int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c);
0321     extern void _TIFFfree(void *p);
0322 
0323     /*
0324     ** Stuff, related to tag handling and creating custom tags.
0325     */
0326     extern int TIFFGetTagListCount(TIFF *);
0327     extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index);
0328 
0329 #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
0330 #define TIFF_VARIABLE -1     /* marker for variable length tags */
0331 #define TIFF_SPP -2          /* marker for SamplesPerPixel tags */
0332 #define TIFF_VARIABLE2 -3    /* marker for uint32_t var-length tags */
0333 
0334 #define FIELD_CUSTOM 65
0335 
0336     typedef struct _TIFFField TIFFField;
0337     typedef struct _TIFFFieldArray TIFFFieldArray;
0338 
0339     extern const TIFFField *TIFFFindField(TIFF *, uint32_t, TIFFDataType);
0340     extern const TIFFField *TIFFFieldWithTag(TIFF *, uint32_t);
0341     extern const TIFFField *TIFFFieldWithName(TIFF *, const char *);
0342 
0343     extern uint32_t TIFFFieldTag(const TIFFField *);
0344     extern const char *TIFFFieldName(const TIFFField *);
0345     extern TIFFDataType TIFFFieldDataType(const TIFFField *);
0346     extern int TIFFFieldPassCount(const TIFFField *);
0347     extern int TIFFFieldReadCount(const TIFFField *);
0348     extern int TIFFFieldWriteCount(const TIFFField *);
0349     extern int
0350     TIFFFieldSetGetSize(const TIFFField *); /* returns internal storage size of
0351                                                TIFFSetGetFieldType in bytes. */
0352     extern int TIFFFieldSetGetCountSize(
0353         const TIFFField *); /* returns size of count parameter 0=none,
0354                                2=uint16_t, 4=uint32_t */
0355     extern int TIFFFieldIsAnonymous(const TIFFField *);
0356 
0357     typedef int (*TIFFVSetMethod)(TIFF *, uint32_t, va_list);
0358     typedef int (*TIFFVGetMethod)(TIFF *, uint32_t, va_list);
0359     typedef void (*TIFFPrintMethod)(TIFF *, FILE *, long);
0360 
0361     typedef struct
0362     {
0363         TIFFVSetMethod vsetfield; /* tag set routine */
0364         TIFFVGetMethod vgetfield; /* tag get routine */
0365         TIFFPrintMethod printdir; /* directory print routine */
0366     } TIFFTagMethods;
0367 
0368     extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
0369     extern void *TIFFGetClientInfo(TIFF *, const char *);
0370     extern void TIFFSetClientInfo(TIFF *, void *, const char *);
0371 
0372     extern void TIFFCleanup(TIFF *tif);
0373     extern void TIFFClose(TIFF *tif);
0374     extern int TIFFFlush(TIFF *tif);
0375     extern int TIFFFlushData(TIFF *tif);
0376     extern int TIFFGetField(TIFF *tif, uint32_t tag, ...);
0377     extern int TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap);
0378     extern int TIFFGetFieldDefaulted(TIFF *tif, uint32_t tag, ...);
0379     extern int TIFFVGetFieldDefaulted(TIFF *tif, uint32_t tag, va_list ap);
0380     extern int TIFFReadDirectory(TIFF *tif);
0381     extern int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff,
0382                                        const TIFFFieldArray *infoarray);
0383     extern int TIFFReadEXIFDirectory(TIFF *tif, toff_t diroff);
0384     extern int TIFFReadGPSDirectory(TIFF *tif, toff_t diroff);
0385     extern uint64_t TIFFScanlineSize64(TIFF *tif);
0386     extern tmsize_t TIFFScanlineSize(TIFF *tif);
0387     extern uint64_t TIFFRasterScanlineSize64(TIFF *tif);
0388     extern tmsize_t TIFFRasterScanlineSize(TIFF *tif);
0389     extern uint64_t TIFFStripSize64(TIFF *tif);
0390     extern tmsize_t TIFFStripSize(TIFF *tif);
0391     extern uint64_t TIFFRawStripSize64(TIFF *tif, uint32_t strip);
0392     extern tmsize_t TIFFRawStripSize(TIFF *tif, uint32_t strip);
0393     extern uint64_t TIFFVStripSize64(TIFF *tif, uint32_t nrows);
0394     extern tmsize_t TIFFVStripSize(TIFF *tif, uint32_t nrows);
0395     extern uint64_t TIFFTileRowSize64(TIFF *tif);
0396     extern tmsize_t TIFFTileRowSize(TIFF *tif);
0397     extern uint64_t TIFFTileSize64(TIFF *tif);
0398     extern tmsize_t TIFFTileSize(TIFF *tif);
0399     extern uint64_t TIFFVTileSize64(TIFF *tif, uint32_t nrows);
0400     extern tmsize_t TIFFVTileSize(TIFF *tif, uint32_t nrows);
0401     extern uint32_t TIFFDefaultStripSize(TIFF *tif, uint32_t request);
0402     extern void TIFFDefaultTileSize(TIFF *, uint32_t *, uint32_t *);
0403     extern int TIFFFileno(TIFF *);
0404     extern int TIFFSetFileno(TIFF *, int);
0405     extern thandle_t TIFFClientdata(TIFF *);
0406     extern thandle_t TIFFSetClientdata(TIFF *, thandle_t);
0407     extern int TIFFGetMode(TIFF *);
0408     extern int TIFFSetMode(TIFF *, int);
0409     extern int TIFFIsTiled(TIFF *);
0410     extern int TIFFIsByteSwapped(TIFF *);
0411     extern int TIFFIsUpSampled(TIFF *);
0412     extern int TIFFIsMSB2LSB(TIFF *);
0413     extern int TIFFIsBigEndian(TIFF *);
0414     extern int TIFFIsBigTIFF(TIFF *);
0415     extern TIFFReadWriteProc TIFFGetReadProc(TIFF *);
0416     extern TIFFReadWriteProc TIFFGetWriteProc(TIFF *);
0417     extern TIFFSeekProc TIFFGetSeekProc(TIFF *);
0418     extern TIFFCloseProc TIFFGetCloseProc(TIFF *);
0419     extern TIFFSizeProc TIFFGetSizeProc(TIFF *);
0420     extern TIFFMapFileProc TIFFGetMapFileProc(TIFF *);
0421     extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF *);
0422     extern uint32_t TIFFCurrentRow(TIFF *);
0423     extern tdir_t TIFFCurrentDirectory(TIFF *);
0424     extern tdir_t TIFFNumberOfDirectories(TIFF *);
0425     extern uint64_t TIFFCurrentDirOffset(TIFF *);
0426     extern uint32_t TIFFCurrentStrip(TIFF *);
0427     extern uint32_t TIFFCurrentTile(TIFF *tif);
0428     extern int TIFFReadBufferSetup(TIFF *tif, void *bp, tmsize_t size);
0429     extern int TIFFWriteBufferSetup(TIFF *tif, void *bp, tmsize_t size);
0430     extern int TIFFSetupStrips(TIFF *);
0431     extern int TIFFWriteCheck(TIFF *, int, const char *);
0432     extern void TIFFFreeDirectory(TIFF *);
0433     extern int TIFFCreateDirectory(TIFF *);
0434     extern int TIFFCreateCustomDirectory(TIFF *, const TIFFFieldArray *);
0435     extern int TIFFCreateEXIFDirectory(TIFF *);
0436     extern int TIFFCreateGPSDirectory(TIFF *);
0437     extern int TIFFLastDirectory(TIFF *);
0438     extern int TIFFSetDirectory(TIFF *, tdir_t);
0439     extern int TIFFSetSubDirectory(TIFF *, uint64_t);
0440     extern int TIFFUnlinkDirectory(TIFF *, tdir_t);
0441     extern int TIFFSetField(TIFF *, uint32_t, ...);
0442     extern int TIFFVSetField(TIFF *, uint32_t, va_list);
0443     extern int TIFFUnsetField(TIFF *, uint32_t);
0444     extern int TIFFWriteDirectory(TIFF *);
0445     extern int TIFFWriteCustomDirectory(TIFF *, uint64_t *);
0446     extern int TIFFCheckpointDirectory(TIFF *);
0447     extern int TIFFRewriteDirectory(TIFF *);
0448     extern int TIFFDeferStrileArrayWriting(TIFF *);
0449     extern int TIFFForceStrileArrayWriting(TIFF *);
0450 
0451 #if defined(c_plusplus) || defined(__cplusplus)
0452     extern void TIFFPrintDirectory(TIFF *, FILE *, long = 0);
0453     extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row,
0454                                 uint16_t sample = 0);
0455     extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row,
0456                                  uint16_t sample = 0);
0457     extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *,
0458                                  int = 0);
0459     extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
0460                                          int = ORIENTATION_BOTLEFT, int = 0);
0461 #else
0462 extern void TIFFPrintDirectory(TIFF *, FILE *, long);
0463 extern int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row,
0464                             uint16_t sample);
0465 extern int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row,
0466                              uint16_t sample);
0467 extern int TIFFReadRGBAImage(TIFF *, uint32_t, uint32_t, uint32_t *, int);
0468 extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
0469                                      int, int);
0470 #endif
0471 
0472     extern int TIFFReadRGBAStrip(TIFF *, uint32_t, uint32_t *);
0473     extern int TIFFReadRGBATile(TIFF *, uint32_t, uint32_t, uint32_t *);
0474     extern int TIFFReadRGBAStripExt(TIFF *, uint32_t, uint32_t *,
0475                                     int stop_on_error);
0476     extern int TIFFReadRGBATileExt(TIFF *, uint32_t, uint32_t, uint32_t *,
0477                                    int stop_on_error);
0478     extern int TIFFRGBAImageOK(TIFF *, char[1024]);
0479     extern int TIFFRGBAImageBegin(TIFFRGBAImage *, TIFF *, int, char[1024]);
0480     extern int TIFFRGBAImageGet(TIFFRGBAImage *, uint32_t *, uint32_t,
0481                                 uint32_t);
0482     extern void TIFFRGBAImageEnd(TIFFRGBAImage *);
0483 
0484     extern const char *TIFFFileName(TIFF *);
0485     extern const char *TIFFSetFileName(TIFF *, const char *);
0486     extern void TIFFError(const char *, const char *, ...)
0487         TIFF_ATTRIBUTE((__format__(__printf__, 2, 3)));
0488     extern void TIFFErrorExt(thandle_t, const char *, const char *, ...)
0489         TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
0490     extern void TIFFWarning(const char *, const char *, ...)
0491         TIFF_ATTRIBUTE((__format__(__printf__, 2, 3)));
0492     extern void TIFFWarningExt(thandle_t, const char *, const char *, ...)
0493         TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
0494     extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
0495     extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
0496     extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
0497     extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
0498 
0499     extern void TIFFWarningExtR(TIFF *, const char *, const char *, ...)
0500         TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
0501     extern void TIFFErrorExtR(TIFF *, const char *, const char *, ...)
0502         TIFF_ATTRIBUTE((__format__(__printf__, 3, 4)));
0503 
0504     typedef struct TIFFOpenOptions TIFFOpenOptions;
0505     extern TIFFOpenOptions *TIFFOpenOptionsAlloc(void);
0506     extern void TIFFOpenOptionsFree(TIFFOpenOptions *);
0507     extern void
0508     TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions *opts,
0509                                         tmsize_t max_single_mem_alloc);
0510     extern void
0511     TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts,
0512                                        TIFFErrorHandlerExtR handler,
0513                                        void *errorhandler_user_data);
0514     extern void
0515     TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions *opts,
0516                                          TIFFErrorHandlerExtR handler,
0517                                          void *warnhandler_user_data);
0518 
0519     extern TIFF *TIFFOpen(const char *, const char *);
0520     extern TIFF *TIFFOpenExt(const char *, const char *, TIFFOpenOptions *opts);
0521 #ifdef __WIN32__
0522     extern TIFF *TIFFOpenW(const wchar_t *, const char *);
0523     extern TIFF *TIFFOpenWExt(const wchar_t *, const char *,
0524                               TIFFOpenOptions *opts);
0525 #endif /* __WIN32__ */
0526     extern TIFF *TIFFFdOpen(int, const char *, const char *);
0527     extern TIFF *TIFFFdOpenExt(int, const char *, const char *,
0528                                TIFFOpenOptions *opts);
0529     extern TIFF *TIFFClientOpen(const char *, const char *, thandle_t,
0530                                 TIFFReadWriteProc, TIFFReadWriteProc,
0531                                 TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
0532                                 TIFFMapFileProc, TIFFUnmapFileProc);
0533     extern TIFF *TIFFClientOpenExt(const char *, const char *, thandle_t,
0534                                    TIFFReadWriteProc, TIFFReadWriteProc,
0535                                    TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
0536                                    TIFFMapFileProc, TIFFUnmapFileProc,
0537                                    TIFFOpenOptions *opts);
0538     extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
0539     extern uint32_t TIFFComputeTile(TIFF *tif, uint32_t x, uint32_t y,
0540                                     uint32_t z, uint16_t s);
0541     extern int TIFFCheckTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z,
0542                              uint16_t s);
0543     extern uint32_t TIFFNumberOfTiles(TIFF *);
0544     extern tmsize_t TIFFReadTile(TIFF *tif, void *buf, uint32_t x, uint32_t y,
0545                                  uint32_t z, uint16_t s);
0546     extern tmsize_t TIFFWriteTile(TIFF *tif, void *buf, uint32_t x, uint32_t y,
0547                                   uint32_t z, uint16_t s);
0548     extern uint32_t TIFFComputeStrip(TIFF *, uint32_t, uint16_t);
0549     extern uint32_t TIFFNumberOfStrips(TIFF *);
0550     extern tmsize_t TIFFReadEncodedStrip(TIFF *tif, uint32_t strip, void *buf,
0551                                          tmsize_t size);
0552     extern tmsize_t TIFFReadRawStrip(TIFF *tif, uint32_t strip, void *buf,
0553                                      tmsize_t size);
0554     extern tmsize_t TIFFReadEncodedTile(TIFF *tif, uint32_t tile, void *buf,
0555                                         tmsize_t size);
0556     extern tmsize_t TIFFReadRawTile(TIFF *tif, uint32_t tile, void *buf,
0557                                     tmsize_t size);
0558     extern int TIFFReadFromUserBuffer(TIFF *tif, uint32_t strile, void *inbuf,
0559                                       tmsize_t insize, void *outbuf,
0560                                       tmsize_t outsize);
0561     extern tmsize_t TIFFWriteEncodedStrip(TIFF *tif, uint32_t strip, void *data,
0562                                           tmsize_t cc);
0563     extern tmsize_t TIFFWriteRawStrip(TIFF *tif, uint32_t strip, void *data,
0564                                       tmsize_t cc);
0565     extern tmsize_t TIFFWriteEncodedTile(TIFF *tif, uint32_t tile, void *data,
0566                                          tmsize_t cc);
0567     extern tmsize_t TIFFWriteRawTile(TIFF *tif, uint32_t tile, void *data,
0568                                      tmsize_t cc);
0569     extern int TIFFDataWidth(
0570         TIFFDataType); /* table of tag datatype widths within TIFF file. */
0571     extern void TIFFSetWriteOffset(TIFF *tif, toff_t off);
0572     extern void TIFFSwabShort(uint16_t *);
0573     extern void TIFFSwabLong(uint32_t *);
0574     extern void TIFFSwabLong8(uint64_t *);
0575     extern void TIFFSwabFloat(float *);
0576     extern void TIFFSwabDouble(double *);
0577     extern void TIFFSwabArrayOfShort(uint16_t *wp, tmsize_t n);
0578     extern void TIFFSwabArrayOfTriples(uint8_t *tp, tmsize_t n);
0579     extern void TIFFSwabArrayOfLong(uint32_t *lp, tmsize_t n);
0580     extern void TIFFSwabArrayOfLong8(uint64_t *lp, tmsize_t n);
0581     extern void TIFFSwabArrayOfFloat(float *fp, tmsize_t n);
0582     extern void TIFFSwabArrayOfDouble(double *dp, tmsize_t n);
0583     extern void TIFFReverseBits(uint8_t *cp, tmsize_t n);
0584     extern const unsigned char *TIFFGetBitRevTable(int);
0585 
0586     extern uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile);
0587     extern uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile);
0588     extern uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile,
0589                                                int *pbErr);
0590     extern uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile,
0591                                                   int *pbErr);
0592 
0593 #ifdef LOGLUV_PUBLIC
0594 #define U_NEU 0.210526316
0595 #define V_NEU 0.473684211
0596 #define UVSCALE 410.
0597     extern double LogL16toY(int);
0598     extern double LogL10toY(int);
0599     extern void XYZtoRGB24(float *, uint8_t *);
0600     extern int uv_decode(double *, double *, int);
0601     extern void LogLuv24toXYZ(uint32_t, float *);
0602     extern void LogLuv32toXYZ(uint32_t, float *);
0603 #if defined(c_plusplus) || defined(__cplusplus)
0604     extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
0605     extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
0606     extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
0607     extern uint32_t LogLuv24fromXYZ(float *, int = SGILOGENCODE_NODITHER);
0608     extern uint32_t LogLuv32fromXYZ(float *, int = SGILOGENCODE_NODITHER);
0609 #else
0610     extern int LogL16fromY(double, int);
0611     extern int LogL10fromY(double, int);
0612     extern int uv_encode(double, double, int);
0613     extern uint32_t LogLuv24fromXYZ(float *, int);
0614     extern uint32_t LogLuv32fromXYZ(float *, int);
0615 #endif
0616 #endif /* LOGLUV_PUBLIC */
0617 
0618     extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB *, const TIFFDisplay *,
0619                                    float *);
0620     extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t,
0621                                 float *, float *, float *);
0622     extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32_t *,
0623                              uint32_t *, uint32_t *);
0624 
0625     extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *, float *, float *);
0626     extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t,
0627                                uint32_t *, uint32_t *, uint32_t *);
0628 
0629     /****************************************************************************
0630      *               O B S O L E T E D    I N T E R F A C E S
0631      *
0632      * Don't use this stuff in your applications, it may be removed in the
0633      *future libtiff versions.
0634      ****************************************************************************/
0635     typedef struct
0636     {
0637         ttag_t field_tag;               /* field's tag */
0638         short field_readcount;          /* read count/TIFF_VARIABLE/TIFF_SPP */
0639         short field_writecount;         /* write count/TIFF_VARIABLE */
0640         TIFFDataType field_type;        /* type of associated data */
0641         unsigned short field_bit;       /* bit in fieldsset bit vector */
0642         unsigned char field_oktochange; /* if true, can change while writing */
0643         unsigned char field_passcount;  /* if true, pass dir count on set */
0644         char *field_name;               /* ASCII name */
0645     } TIFFFieldInfo;
0646 
0647     extern int TIFFMergeFieldInfo(TIFF *, const TIFFFieldInfo[], uint32_t);
0648 
0649 #if defined(c_plusplus) || defined(__cplusplus)
0650 }
0651 #endif
0652 
0653 #endif /* _TIFFIO_ */