roentgen b75cab
/* $Id: tiffio.h,v 1.91 2012-07-29 15:45:29 tgl Exp $ */
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Copyright (c) 1988-1997 Sam Leffler
roentgen b75cab
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
roentgen b75cab
 *
roentgen b75cab
 * Permission to use, copy, modify, distribute, and sell this software and
roentgen b75cab
 * its documentation for any purpose is hereby granted without fee, provided
roentgen b75cab
 * that (i) the above copyright notices and this permission notice appear in
roentgen b75cab
 * all copies of the software and related documentation, and (ii) the names of
roentgen b75cab
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
roentgen b75cab
 * publicity relating to the software without the specific, prior written
roentgen b75cab
 * permission of Sam Leffler and Silicon Graphics.
roentgen b75cab
 *
roentgen b75cab
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
roentgen b75cab
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
roentgen b75cab
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
roentgen b75cab
 *
roentgen b75cab
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
roentgen b75cab
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
roentgen b75cab
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
roentgen b75cab
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
roentgen b75cab
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
roentgen b75cab
 * OF THIS SOFTWARE.
roentgen b75cab
 */
roentgen b75cab
roentgen b75cab
#ifndef _TIFFIO_
roentgen b75cab
#define	_TIFFIO_
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * TIFF I/O Library Definitions.
roentgen b75cab
 */
roentgen b75cab
#include "tiff.h"
roentgen b75cab
#include "tiffvers.h"
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * TIFF is defined as an incomplete type to hide the
roentgen b75cab
 * library's internal data structures from clients.
roentgen b75cab
 */
roentgen b75cab
typedef struct tiff TIFF;
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * The following typedefs define the intrinsic size of
roentgen b75cab
 * data types used in the *exported* interfaces.  These
roentgen b75cab
 * definitions depend on the proper definition of types
roentgen b75cab
 * in tiff.h.  Note also that the varargs interface used
roentgen b75cab
 * to pass tag types and values uses the types defined in
roentgen b75cab
 * tiff.h directly.
roentgen b75cab
 *
roentgen b75cab
 * NB: ttag_t is unsigned int and not unsigned short because
roentgen b75cab
 *     ANSI C requires that the type before the ellipsis be a
roentgen b75cab
 *     promoted type (i.e. one of int, unsigned int, pointer,
roentgen b75cab
 *     or double) and because we defined pseudo-tags that are
roentgen b75cab
 *     outside the range of legal Aldus-assigned tags.
roentgen b75cab
 * NB: tsize_t is int32 and not uint32 because some functions
roentgen b75cab
 *     return -1.
roentgen b75cab
 * NB: toff_t is not off_t for many reasons; TIFFs max out at
roentgen b75cab
 *     32-bit file offsets, and BigTIFF maxes out at 64-bit
roentgen b75cab
 *     offsets being the most important, and to ensure use of
roentgen b75cab
 *     a consistently unsigned type across architectures.
roentgen b75cab
 *     Prior to libtiff 4.0, this was an unsigned 32 bit type.
roentgen b75cab
 */
roentgen b75cab
/*
roentgen b75cab
 * this is the machine addressing size type, only it's signed, so make it
roentgen b75cab
 * int32 on 32bit machines, int64 on 64bit machines
roentgen b75cab
 */
roentgen b75cab
typedef TIFF_SSIZE_T tmsize_t;
roentgen b75cab
typedef uint64 toff_t;          /* file offset */
roentgen b75cab
/* the following are deprecated and should be replaced by their defining
roentgen b75cab
   counterparts */
roentgen b75cab
typedef uint32 ttag_t;          /* directory tag */
roentgen b75cab
typedef uint16 tdir_t;          /* directory index */
roentgen b75cab
typedef uint16 tsample_t;       /* sample number */
roentgen b75cab
typedef uint32 tstrile_t;       /* strip or tile number */
roentgen b75cab
typedef tstrile_t tstrip_t;     /* strip number */
roentgen b75cab
typedef tstrile_t ttile_t;      /* tile number */
roentgen b75cab
typedef tmsize_t tsize_t;       /* i/o size in bytes */
roentgen b75cab
typedef void* tdata_t;          /* image data ref */
roentgen b75cab
roentgen b75cab
#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
roentgen b75cab
#define __WIN32__
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c
roentgen b75cab
 * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c).
roentgen b75cab
 *
roentgen b75cab
 * By default tif_unix.c is assumed.
roentgen b75cab
 */
roentgen b75cab
roentgen b75cab
#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
roentgen b75cab
#  if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO)
roentgen b75cab
#    define AVOID_WIN32_FILEIO
roentgen b75cab
#  endif
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#if defined(USE_WIN32_FILEIO)
roentgen b75cab
# define VC_EXTRALEAN
roentgen b75cab
# include <windows.h></windows.h>
roentgen b75cab
# ifdef __WIN32__
roentgen b75cab
DECLARE_HANDLE(thandle_t);     /* Win32 file handle */
roentgen b75cab
# else
roentgen b75cab
typedef HFILE thandle_t;       /* client data handle */
roentgen b75cab
# endif /* __WIN32__ */
roentgen b75cab
#else
roentgen b75cab
typedef void* thandle_t;       /* client data handle */
roentgen b75cab
#endif /* USE_WIN32_FILEIO */
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Flags to pass to TIFFPrintDirectory to control
roentgen b75cab
 * printing of data structures that are potentially
roentgen b75cab
 * very large.   Bit-or these flags to enable printing
roentgen b75cab
 * multiple items.
roentgen b75cab
 */
roentgen b75cab
#define TIFFPRINT_NONE	       0x0    /* no extra info */
roentgen b75cab
#define TIFFPRINT_STRIPS       0x1    /* strips/tiles info */
roentgen b75cab
#define TIFFPRINT_CURVES       0x2    /* color/gray response curves */
roentgen b75cab
#define TIFFPRINT_COLORMAP     0x4    /* colormap */
roentgen b75cab
#define TIFFPRINT_JPEGQTABLES  0x100  /* JPEG Q matrices */
roentgen b75cab
#define TIFFPRINT_JPEGACTABLES 0x200  /* JPEG AC tables */
roentgen b75cab
#define TIFFPRINT_JPEGDCTABLES 0x200  /* JPEG DC tables */
roentgen b75cab
roentgen b75cab
/* 
roentgen b75cab
 * Colour conversion stuff
roentgen b75cab
 */
roentgen b75cab
roentgen b75cab
/* reference white */
roentgen b75cab
#define D65_X0 (95.0470F)
roentgen b75cab
#define D65_Y0 (100.0F)
roentgen b75cab
#define D65_Z0 (108.8827F)
roentgen b75cab
roentgen b75cab
#define D50_X0 (96.4250F)
roentgen b75cab
#define D50_Y0 (100.0F)
roentgen b75cab
#define D50_Z0 (82.4680F)
roentgen b75cab
roentgen b75cab
/* Structure for holding information about a display device. */
roentgen b75cab
roentgen b75cab
typedef unsigned char TIFFRGBValue;               /* 8-bit samples */
roentgen b75cab
roentgen b75cab
typedef struct {
roentgen b75cab
	float d_mat[3][3];                        /* XYZ -> luminance matrix */
roentgen b75cab
	float d_YCR;                              /* Light o/p for reference white */
roentgen b75cab
	float d_YCG;
roentgen b75cab
	float d_YCB;
roentgen b75cab
	uint32 d_Vrwr;                            /* Pixel values for ref. white */
roentgen b75cab
	uint32 d_Vrwg;
roentgen b75cab
	uint32 d_Vrwb;
roentgen b75cab
	float d_Y0R;                              /* Residual light for black pixel */
roentgen b75cab
	float d_Y0G;
roentgen b75cab
	float d_Y0B;
roentgen b75cab
	float d_gammaR;                           /* Gamma values for the three guns */
roentgen b75cab
	float d_gammaG;
roentgen b75cab
	float d_gammaB;
roentgen b75cab
} TIFFDisplay;
roentgen b75cab
roentgen b75cab
typedef struct {                                  /* YCbCr->RGB support */
roentgen b75cab
	TIFFRGBValue* clamptab;                   /* range clamping table */
roentgen b75cab
	int* Cr_r_tab;
roentgen b75cab
	int* Cb_b_tab;
roentgen b75cab
	int32* Cr_g_tab;
roentgen b75cab
	int32* Cb_g_tab;
roentgen b75cab
	int32* Y_tab;
roentgen b75cab
} TIFFYCbCrToRGB;
roentgen b75cab
roentgen b75cab
typedef struct {                                  /* CIE Lab 1976->RGB support */
roentgen b75cab
	int range;                                /* Size of conversion table */
roentgen b75cab
#define CIELABTORGB_TABLE_RANGE 1500
roentgen b75cab
	float rstep, gstep, bstep;
roentgen b75cab
	float X0, Y0, Z0;                         /* Reference white point */
roentgen b75cab
	TIFFDisplay display;
roentgen b75cab
	float Yr2r[CIELABTORGB_TABLE_RANGE + 1];  /* Conversion of Yr to r */
roentgen b75cab
	float Yg2g[CIELABTORGB_TABLE_RANGE + 1];  /* Conversion of Yg to g */
roentgen b75cab
	float Yb2b[CIELABTORGB_TABLE_RANGE + 1];  /* Conversion of Yb to b */
roentgen b75cab
} TIFFCIELabToRGB;
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * RGBA-style image support.
roentgen b75cab
 */
roentgen b75cab
typedef struct _TIFFRGBAImage TIFFRGBAImage;
roentgen b75cab
/*
roentgen b75cab
 * The image reading and conversion routines invoke
roentgen b75cab
 * ``put routines'' to copy/image/whatever tiles of
roentgen b75cab
 * raw image data.  A default set of routines are 
roentgen b75cab
 * provided to convert/copy raw image data to 8-bit
roentgen b75cab
 * packed ABGR format rasters.  Applications can supply
roentgen b75cab
 * alternate routines that unpack the data into a
roentgen b75cab
 * different format or, for example, unpack the data
roentgen b75cab
 * and draw the unpacked raster on the display.
roentgen b75cab
 */
roentgen b75cab
typedef void (*tileContigRoutine)
roentgen b75cab
    (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
roentgen b75cab
	unsigned char*);
roentgen b75cab
typedef void (*tileSeparateRoutine)
roentgen b75cab
    (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
roentgen b75cab
	unsigned char*, unsigned char*, unsigned char*, unsigned char*);
roentgen b75cab
/*
roentgen b75cab
 * RGBA-reader state.
roentgen b75cab
 */
roentgen b75cab
struct _TIFFRGBAImage {
roentgen b75cab
	TIFF* tif;                              /* image handle */
roentgen b75cab
	int stoponerr;                          /* stop on read error */
roentgen b75cab
	int isContig;                           /* data is packed/separate */
roentgen b75cab
	int alpha;                              /* type of alpha data present */
roentgen b75cab
	uint32 width;                           /* image width */
roentgen b75cab
	uint32 height;                          /* image height */
roentgen b75cab
	uint16 bitspersample;                   /* image bits/sample */
roentgen b75cab
	uint16 samplesperpixel;                 /* image samples/pixel */
roentgen b75cab
	uint16 orientation;                     /* image orientation */
roentgen b75cab
	uint16 req_orientation;                 /* requested orientation */
roentgen b75cab
	uint16 photometric;                     /* image photometric interp */
roentgen b75cab
	uint16* redcmap;                        /* colormap pallete */
roentgen b75cab
	uint16* greencmap;
roentgen b75cab
	uint16* bluecmap;
roentgen b75cab
	/* get image data routine */
roentgen b75cab
	int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
roentgen b75cab
	/* put decoded strip/tile */
roentgen b75cab
	union {
roentgen b75cab
	    void (*any)(TIFFRGBAImage*);
roentgen b75cab
	    tileContigRoutine contig;
roentgen b75cab
	    tileSeparateRoutine separate;
roentgen b75cab
	} put;
roentgen b75cab
	TIFFRGBValue* Map;                      /* sample mapping array */
roentgen b75cab
	uint32** BWmap;                         /* black&white map */
roentgen b75cab
	uint32** PALmap;                        /* palette image map */
roentgen b75cab
	TIFFYCbCrToRGB* ycbcr;                  /* YCbCr conversion state */
roentgen b75cab
	TIFFCIELabToRGB* cielab;                /* CIE L*a*b conversion state */
roentgen b75cab
roentgen b75cab
	uint8* UaToAa;                          /* Unassociated alpha to associated alpha convertion LUT */
roentgen b75cab
	uint8* Bitdepth16To8;                   /* LUT for conversion from 16bit to 8bit values */
roentgen b75cab
roentgen b75cab
	int row_offset;
roentgen b75cab
	int col_offset;
roentgen b75cab
};
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Macros for extracting components from the
roentgen b75cab
 * packed ABGR form returned by TIFFReadRGBAImage.
roentgen b75cab
 */
roentgen b75cab
#define TIFFGetR(abgr) ((abgr) & 0xff)
roentgen b75cab
#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
roentgen b75cab
#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
roentgen b75cab
#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * A CODEC is a software package that implements decoding,
roentgen b75cab
 * encoding, or decoding+encoding of a compression algorithm.
roentgen b75cab
 * The library provides a collection of builtin codecs.
roentgen b75cab
 * More codecs may be registered through calls to the library
roentgen b75cab
 * and/or the builtin implementations may be overridden.
roentgen b75cab
 */
roentgen b75cab
typedef int (*TIFFInitMethod)(TIFF*, int);
roentgen b75cab
typedef struct {
roentgen b75cab
	char* name;
roentgen b75cab
	uint16 scheme;
roentgen b75cab
	TIFFInitMethod init;
roentgen b75cab
} TIFFCodec;
roentgen b75cab
roentgen b75cab
#include <stdio.h></stdio.h>
roentgen b75cab
#include <stdarg.h></stdarg.h>
roentgen b75cab
roentgen b75cab
/* share internal LogLuv conversion routines? */
roentgen b75cab
#ifndef LOGLUV_PUBLIC
roentgen b75cab
#define LOGLUV_PUBLIC 1
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#if !defined(__GNUC__) && !defined(__attribute__)
roentgen b75cab
#  define __attribute__(x) /*nothing*/
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#if defined(c_plusplus) || defined(__cplusplus)
roentgen b75cab
extern "C" {
roentgen b75cab
#endif
roentgen b75cab
typedef void (*TIFFErrorHandler)(const char*, const char*, va_list);
roentgen b75cab
typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list);
roentgen b75cab
typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t);
roentgen b75cab
typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
roentgen b75cab
typedef int (*TIFFCloseProc)(thandle_t);
roentgen b75cab
typedef toff_t (*TIFFSizeProc)(thandle_t);
roentgen b75cab
typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size);
roentgen b75cab
typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size);
roentgen b75cab
typedef void (*TIFFExtendProc)(TIFF*);
roentgen b75cab
roentgen b75cab
extern const char* TIFFGetVersion(void);
roentgen b75cab
roentgen b75cab
extern const TIFFCodec* TIFFFindCODEC(uint16);
roentgen b75cab
extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
roentgen b75cab
extern void TIFFUnRegisterCODEC(TIFFCodec*);
roentgen b75cab
extern int TIFFIsCODECConfigured(uint16);
roentgen b75cab
extern TIFFCodec* TIFFGetConfiguredCODECs(void);
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Auxiliary functions.
roentgen b75cab
 */
roentgen b75cab
roentgen b75cab
extern void* _TIFFmalloc(tmsize_t s);
roentgen b75cab
extern void* _TIFFrealloc(void* p, tmsize_t s);
roentgen b75cab
extern void _TIFFmemset(void* p, int v, tmsize_t c);
roentgen b75cab
extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);
roentgen b75cab
extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c);
roentgen b75cab
extern void _TIFFfree(void* p);
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
** Stuff, related to tag handling and creating custom tags.
roentgen b75cab
*/
roentgen b75cab
extern int TIFFGetTagListCount( TIFF * );
roentgen b75cab
extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index );
roentgen b75cab
    
roentgen b75cab
#define TIFF_ANY       TIFF_NOTYPE     /* for field descriptor searching */
roentgen b75cab
#define TIFF_VARIABLE  -1              /* marker for variable length tags */
roentgen b75cab
#define TIFF_SPP       -2              /* marker for SamplesPerPixel tags */
roentgen b75cab
#define TIFF_VARIABLE2 -3              /* marker for uint32 var-length tags */
roentgen b75cab
roentgen b75cab
#define FIELD_CUSTOM    65
roentgen b75cab
roentgen b75cab
typedef struct _TIFFField TIFFField;
roentgen b75cab
typedef struct _TIFFFieldArray TIFFFieldArray;
roentgen b75cab
roentgen b75cab
extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType);
roentgen b75cab
extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32);
roentgen b75cab
extern const TIFFField* TIFFFieldWithName(TIFF*, const char *);
roentgen b75cab
roentgen b75cab
extern uint32 TIFFFieldTag(const TIFFField*);
roentgen b75cab
extern const char* TIFFFieldName(const TIFFField*);
roentgen b75cab
extern TIFFDataType TIFFFieldDataType(const TIFFField*);
roentgen b75cab
extern int TIFFFieldPassCount(const TIFFField*);
roentgen b75cab
extern int TIFFFieldReadCount(const TIFFField*);
roentgen b75cab
extern int TIFFFieldWriteCount(const TIFFField*);
roentgen b75cab
roentgen b75cab
typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list);
roentgen b75cab
typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list);
roentgen b75cab
typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long);
roentgen b75cab
roentgen b75cab
typedef struct {
roentgen b75cab
    TIFFVSetMethod vsetfield; /* tag set routine */
roentgen b75cab
    TIFFVGetMethod vgetfield; /* tag get routine */
roentgen b75cab
    TIFFPrintMethod printdir; /* directory print routine */
roentgen b75cab
} TIFFTagMethods;
roentgen b75cab
roentgen b75cab
extern  TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
roentgen b75cab
extern  void *TIFFGetClientInfo(TIFF *, const char *);
roentgen b75cab
extern  void TIFFSetClientInfo(TIFF *, void *, const char *);
roentgen b75cab
roentgen b75cab
extern void TIFFCleanup(TIFF* tif);
roentgen b75cab
extern void TIFFClose(TIFF* tif);
roentgen b75cab
extern int TIFFFlush(TIFF* tif);
roentgen b75cab
extern int TIFFFlushData(TIFF* tif);
roentgen b75cab
extern int TIFFGetField(TIFF* tif, uint32 tag, ...);
roentgen b75cab
extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap);
roentgen b75cab
extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...);
roentgen b75cab
extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap);
roentgen b75cab
extern int TIFFReadDirectory(TIFF* tif);
roentgen b75cab
extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray);
roentgen b75cab
extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff);
roentgen b75cab
extern uint64 TIFFScanlineSize64(TIFF* tif);
roentgen b75cab
extern tmsize_t TIFFScanlineSize(TIFF* tif);
roentgen b75cab
extern uint64 TIFFRasterScanlineSize64(TIFF* tif);
roentgen b75cab
extern tmsize_t TIFFRasterScanlineSize(TIFF* tif);
roentgen b75cab
extern uint64 TIFFStripSize64(TIFF* tif);
roentgen b75cab
extern tmsize_t TIFFStripSize(TIFF* tif);
roentgen b75cab
extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip);
roentgen b75cab
extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip);
roentgen b75cab
extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows);
roentgen b75cab
extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows);
roentgen b75cab
extern uint64 TIFFTileRowSize64(TIFF* tif);
roentgen b75cab
extern tmsize_t TIFFTileRowSize(TIFF* tif);
roentgen b75cab
extern uint64 TIFFTileSize64(TIFF* tif);
roentgen b75cab
extern tmsize_t TIFFTileSize(TIFF* tif);
roentgen b75cab
extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows);
roentgen b75cab
extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows);
roentgen b75cab
extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request);
roentgen b75cab
extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
roentgen b75cab
extern int TIFFFileno(TIFF*);
roentgen b75cab
extern int TIFFSetFileno(TIFF*, int);
roentgen b75cab
extern thandle_t TIFFClientdata(TIFF*);
roentgen b75cab
extern thandle_t TIFFSetClientdata(TIFF*, thandle_t);
roentgen b75cab
extern int TIFFGetMode(TIFF*);
roentgen b75cab
extern int TIFFSetMode(TIFF*, int);
roentgen b75cab
extern int TIFFIsTiled(TIFF*);
roentgen b75cab
extern int TIFFIsByteSwapped(TIFF*);
roentgen b75cab
extern int TIFFIsUpSampled(TIFF*);
roentgen b75cab
extern int TIFFIsMSB2LSB(TIFF*);
roentgen b75cab
extern int TIFFIsBigEndian(TIFF*);
roentgen b75cab
extern TIFFReadWriteProc TIFFGetReadProc(TIFF*);
roentgen b75cab
extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*);
roentgen b75cab
extern TIFFSeekProc TIFFGetSeekProc(TIFF*);                                                          
roentgen b75cab
extern TIFFCloseProc TIFFGetCloseProc(TIFF*);
roentgen b75cab
extern TIFFSizeProc TIFFGetSizeProc(TIFF*);
roentgen b75cab
extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*);
roentgen b75cab
extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*);
roentgen b75cab
extern uint32 TIFFCurrentRow(TIFF*);
roentgen b75cab
extern uint16 TIFFCurrentDirectory(TIFF*);
roentgen b75cab
extern uint16 TIFFNumberOfDirectories(TIFF*);
roentgen b75cab
extern uint64 TIFFCurrentDirOffset(TIFF*);
roentgen b75cab
extern uint32 TIFFCurrentStrip(TIFF*);
roentgen b75cab
extern uint32 TIFFCurrentTile(TIFF* tif);
roentgen b75cab
extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size);
roentgen b75cab
extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size);  
roentgen b75cab
extern int TIFFSetupStrips(TIFF *);
roentgen b75cab
extern int TIFFWriteCheck(TIFF*, int, const char *);
roentgen b75cab
extern void TIFFFreeDirectory(TIFF*);
roentgen b75cab
extern int TIFFCreateDirectory(TIFF*);
roentgen b75cab
extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*);
roentgen b75cab
extern int TIFFCreateEXIFDirectory(TIFF*);
roentgen b75cab
extern int TIFFLastDirectory(TIFF*);
roentgen b75cab
extern int TIFFSetDirectory(TIFF*, uint16);
roentgen b75cab
extern int TIFFSetSubDirectory(TIFF*, uint64);
roentgen b75cab
extern int TIFFUnlinkDirectory(TIFF*, uint16);
roentgen b75cab
extern int TIFFSetField(TIFF*, uint32, ...);
roentgen b75cab
extern int TIFFVSetField(TIFF*, uint32, va_list);
roentgen b75cab
extern int TIFFUnsetField(TIFF*, uint32);
roentgen b75cab
extern int TIFFWriteDirectory(TIFF *);
roentgen b75cab
extern int TIFFWriteCustomDirectory(TIFF *, uint64 *);
roentgen b75cab
extern int TIFFCheckpointDirectory(TIFF *);
roentgen b75cab
extern int TIFFRewriteDirectory(TIFF *);
roentgen b75cab
roentgen b75cab
#if defined(c_plusplus) || defined(__cplusplus)
roentgen b75cab
extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
roentgen b75cab
extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
roentgen b75cab
extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
roentgen b75cab
extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
roentgen b75cab
extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*,
roentgen b75cab
    int = ORIENTATION_BOTLEFT, int = 0);
roentgen b75cab
#else
roentgen b75cab
extern void TIFFPrintDirectory(TIFF*, FILE*, long);
roentgen b75cab
extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
roentgen b75cab
extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
roentgen b75cab
extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
roentgen b75cab
extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int);
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * );
roentgen b75cab
extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
roentgen b75cab
extern int TIFFRGBAImageOK(TIFF*, char [1024]);
roentgen b75cab
extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
roentgen b75cab
extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
roentgen b75cab
extern void TIFFRGBAImageEnd(TIFFRGBAImage*);
roentgen b75cab
extern TIFF* TIFFOpen(const char*, const char*);
roentgen 71f5e9
roentgen 71f5e9
/**************************************************************************
roentgen 71f5e9
 *   64-bit to 64-bit  TIFF support
roentgen 71f5e9
 **************************************************************************/
roentgen 71f5e9
roentgen 71f5e9
int TIFFRGBAImageBegin_64(TIFFRGBAImage *img, TIFF *tif, int stop, char emsg[1024]);
roentgen 71f5e9
int TIFFRGBAImageGet_64(TIFFRGBAImage *img, uint64 *raster, uint32 w, uint32 h);
roentgen 71f5e9
int TIFFReadRGBAStrip_64(TIFF *tif, uint32 row, uint64 *raster);
roentgen 71f5e9
int TIFFReadRGBATile_64(TIFF *tif, uint32 x, uint32 y, uint64 *raster);
roentgen 71f5e9
roentgen b75cab
# ifdef __WIN32__
roentgen b75cab
extern TIFF* TIFFOpenW(const wchar_t*, const char*);
roentgen b75cab
# endif /* __WIN32__ */
roentgen b75cab
extern TIFF* TIFFFdOpen(int, const char*, const char*);
roentgen b75cab
extern TIFF* TIFFClientOpen(const char*, const char*,
roentgen b75cab
	    thandle_t,
roentgen b75cab
	    TIFFReadWriteProc, TIFFReadWriteProc,
roentgen b75cab
	    TIFFSeekProc, TIFFCloseProc,
roentgen b75cab
	    TIFFSizeProc,
roentgen b75cab
	    TIFFMapFileProc, TIFFUnmapFileProc);
roentgen b75cab
extern const char* TIFFFileName(TIFF*);
roentgen b75cab
extern const char* TIFFSetFileName(TIFF*, const char *);
roentgen b75cab
extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3)));
roentgen b75cab
extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4)));
roentgen b75cab
extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3)));
roentgen b75cab
extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4)));
roentgen b75cab
extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
roentgen b75cab
extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
roentgen b75cab
extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
roentgen b75cab
extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
roentgen b75cab
extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
roentgen b75cab
extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
roentgen b75cab
extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
roentgen b75cab
extern uint32 TIFFNumberOfTiles(TIFF*);
roentgen b75cab
extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);  
roentgen b75cab
extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
roentgen b75cab
extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16);
roentgen b75cab
extern uint32 TIFFNumberOfStrips(TIFF*);
roentgen b75cab
extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
roentgen b75cab
extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);  
roentgen b75cab
extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);  
roentgen b75cab
extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);  
roentgen b75cab
extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
roentgen b75cab
extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);  
roentgen b75cab
extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);  
roentgen b75cab
extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);  
roentgen b75cab
extern int TIFFDataWidth(TIFFDataType);    /* table of tag datatype widths */
roentgen b75cab
extern void TIFFSetWriteOffset(TIFF* tif, toff_t off);
roentgen b75cab
extern void TIFFSwabShort(uint16*);
roentgen b75cab
extern void TIFFSwabLong(uint32*);
roentgen b75cab
extern void TIFFSwabLong8(uint64*);
roentgen b75cab
extern void TIFFSwabFloat(float*);
roentgen b75cab
extern void TIFFSwabDouble(double*);
roentgen b75cab
extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n);
roentgen b75cab
extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n);
roentgen b75cab
extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n);
roentgen b75cab
extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n);
roentgen b75cab
extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n);
roentgen b75cab
extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n);
roentgen b75cab
extern void TIFFReverseBits(uint8* cp, tmsize_t n);
roentgen b75cab
extern const unsigned char* TIFFGetBitRevTable(int);
roentgen b75cab
roentgen b75cab
#ifdef LOGLUV_PUBLIC
roentgen b75cab
#define U_NEU		0.210526316
roentgen b75cab
#define V_NEU		0.473684211
roentgen b75cab
#define UVSCALE		410.
roentgen b75cab
extern double LogL16toY(int);
roentgen b75cab
extern double LogL10toY(int);
roentgen b75cab
extern void XYZtoRGB24(float*, uint8*);
roentgen b75cab
extern int uv_decode(double*, double*, int);
roentgen b75cab
extern void LogLuv24toXYZ(uint32, float*);
roentgen b75cab
extern void LogLuv32toXYZ(uint32, float*);
roentgen b75cab
#if defined(c_plusplus) || defined(__cplusplus)
roentgen b75cab
extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
roentgen b75cab
extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
roentgen b75cab
extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
roentgen b75cab
extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER);
roentgen b75cab
extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER);
roentgen b75cab
#else
roentgen b75cab
extern int LogL16fromY(double, int);
roentgen b75cab
extern int LogL10fromY(double, int);
roentgen b75cab
extern int uv_encode(double, double, int);
roentgen b75cab
extern uint32 LogLuv24fromXYZ(float*, int);
roentgen b75cab
extern uint32 LogLuv32fromXYZ(float*, int);
roentgen b75cab
#endif
roentgen b75cab
#endif /* LOGLUV_PUBLIC */
roentgen b75cab
roentgen b75cab
extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*);
roentgen b75cab
extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32,
roentgen b75cab
    float *, float *, float *);
roentgen b75cab
extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float,
roentgen b75cab
    uint32 *, uint32 *, uint32 *);
roentgen b75cab
roentgen b75cab
extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*);
roentgen b75cab
extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
roentgen b75cab
    uint32 *, uint32 *, uint32 *);
roentgen b75cab
roentgen b75cab
/****************************************************************************
roentgen b75cab
 *               O B S O L E T E D    I N T E R F A C E S
roentgen b75cab
 *
roentgen b75cab
 * Don't use this stuff in your applications, it may be removed in the future
roentgen b75cab
 * libtiff versions.
roentgen b75cab
 ****************************************************************************/
roentgen b75cab
typedef	struct {
roentgen b75cab
	ttag_t	field_tag;		/* field's tag */
roentgen b75cab
	short	field_readcount;	/* read count/TIFF_VARIABLE/TIFF_SPP */
roentgen b75cab
	short	field_writecount;	/* write count/TIFF_VARIABLE */
roentgen b75cab
	TIFFDataType field_type;	/* type of associated data */
roentgen b75cab
        unsigned short field_bit;	/* bit in fieldsset bit vector */
roentgen b75cab
	unsigned char field_oktochange;	/* if true, can change while writing */
roentgen b75cab
	unsigned char field_passcount;	/* if true, pass dir count on set */
roentgen b75cab
	char	*field_name;		/* ASCII name */
roentgen b75cab
} TIFFFieldInfo;
roentgen b75cab
roentgen b75cab
extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32);
roentgen b75cab
        
roentgen b75cab
#if defined(c_plusplus) || defined(__cplusplus)
roentgen b75cab
}
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#endif /* _TIFFIO_ */
roentgen b75cab
roentgen b75cab
/* vim: set ts=8 sts=8 sw=8 noet: */
roentgen b75cab
/*
roentgen b75cab
 * Local Variables:
roentgen b75cab
 * mode: c
roentgen b75cab
 * c-basic-offset: 8
roentgen b75cab
 * fill-column: 78
roentgen b75cab
 * End:
roentgen b75cab
 */