1793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/* $Id: tiffio.h,v 1.90 2012-06-06 04:58:00 fwarmerdam Exp $ */
2793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
3793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
4793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Copyright (c) 1988-1997 Sam Leffler
5793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
7793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Permission to use, copy, modify, distribute, and sell this software and
8793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * its documentation for any purpose is hereby granted without fee, provided
9793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * that (i) the above copyright notices and this permission notice appear in
10793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * all copies of the software and related documentation, and (ii) the names of
11793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Sam Leffler and Silicon Graphics may not be used in any advertising or
12793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * publicity relating to the software without the specific, prior written
13793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * permission of Sam Leffler and Silicon Graphics.
14793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
15793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
19793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * OF THIS SOFTWARE.
25793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
26793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
27793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#ifndef _TIFFIO_
28793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define	_TIFFIO_
29793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
30793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
31793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * TIFF I/O Library Definitions.
32793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
33793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include "tiff.h"
34793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include "tiffvers.h"
35793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
36793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
37793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * TIFF is defined as an incomplete type to hide the
38793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * library's internal data structures from clients.
39793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
40793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef struct tiff TIFF;
41793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
42793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
43793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * The following typedefs define the intrinsic size of
44793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * data types used in the *exported* interfaces.  These
45793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * definitions depend on the proper definition of types
46793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * in tiff.h.  Note also that the varargs interface used
47793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * to pass tag types and values uses the types defined in
48793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * tiff.h directly.
49793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
50793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * NB: ttag_t is unsigned int and not unsigned short because
51793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *     ANSI C requires that the type before the ellipsis be a
52793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *     promoted type (i.e. one of int, unsigned int, pointer,
53793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *     or double) and because we defined pseudo-tags that are
54793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *     outside the range of legal Aldus-assigned tags.
55793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * NB: tsize_t is int32 and not uint32 because some functions
56793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *     return -1.
57793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * NB: toff_t is not off_t for many reasons; TIFFs max out at
58793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *     32-bit file offsets, and BigTIFF maxes out at 64-bit
59793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *     offsets being the most important, and to ensure use of
60793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *     a consistently unsigned type across architectures.
61793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *     Prior to libtiff 4.0, this was an unsigned 32 bit type.
62793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
63793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
64793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * this is the machine addressing size type, only it's signed, so make it
65793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * int32 on 32bit machines, int64 on 64bit machines
66793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
67793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef TIFF_SSIZE_T tmsize_t;
68793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef uint64 toff_t;          /* file offset */
69793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/* the following are deprecated and should be replaced by their defining
70793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler   counterparts */
71793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef uint32 ttag_t;          /* directory tag */
72793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef uint16 tdir_t;          /* directory index */
73793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef uint16 tsample_t;       /* sample number */
74793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef uint32 tstrile_t;       /* strip or tile number */
75793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef tstrile_t tstrip_t;     /* strip number */
76793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef tstrile_t ttile_t;      /* tile number */
77793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef tmsize_t tsize_t;       /* i/o size in bytes */
78793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef void* tdata_t;          /* image data ref */
79793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
80793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
81793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define __WIN32__
82793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif
83793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
84793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
85793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c
86793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c).
87793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
88793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * By default tif_unix.c is assumed.
89793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
90793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
91793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
92793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#  if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO)
93793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#    define AVOID_WIN32_FILEIO
94793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#  endif
95793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif
96793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
97793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#if defined(USE_WIN32_FILEIO)
98793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler# define VC_EXTRALEAN
99793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler# include <windows.h>
100793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler# ifdef __WIN32__
101793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerDECLARE_HANDLE(thandle_t);     /* Win32 file handle */
102793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler# else
103793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef HFILE thandle_t;       /* client data handle */
104793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler# endif /* __WIN32__ */
105793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#else
106793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef void* thandle_t;       /* client data handle */
107793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif /* USE_WIN32_FILEIO */
108793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
109793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
110793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Flags to pass to TIFFPrintDirectory to control
111793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * printing of data structures that are potentially
112793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * very large.   Bit-or these flags to enable printing
113793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * multiple items.
114793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
115793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFPRINT_NONE	       0x0    /* no extra info */
116793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFPRINT_STRIPS       0x1    /* strips/tiles info */
117793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFPRINT_CURVES       0x2    /* color/gray response curves */
118793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFPRINT_COLORMAP     0x4    /* colormap */
119793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFPRINT_JPEGQTABLES  0x100  /* JPEG Q matrices */
120793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFPRINT_JPEGACTABLES 0x200  /* JPEG AC tables */
121793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFPRINT_JPEGDCTABLES 0x200  /* JPEG DC tables */
122793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
123793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
124793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Colour conversion stuff
125793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
126793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
127793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/* reference white */
128793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define D65_X0 (95.0470F)
129793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define D65_Y0 (100.0F)
130793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define D65_Z0 (108.8827F)
131793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
132793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define D50_X0 (96.4250F)
133793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define D50_Y0 (100.0F)
134793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define D50_Z0 (82.4680F)
135793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
136793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/* Structure for holding information about a display device. */
137793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
138793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef unsigned char TIFFRGBValue;               /* 8-bit samples */
139793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
140793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef struct {
141793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float d_mat[3][3];                        /* XYZ -> luminance matrix */
142793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float d_YCR;                              /* Light o/p for reference white */
143793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float d_YCG;
144793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float d_YCB;
145793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint32 d_Vrwr;                            /* Pixel values for ref. white */
146793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint32 d_Vrwg;
147793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint32 d_Vrwb;
148793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float d_Y0R;                              /* Residual light for black pixel */
149793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float d_Y0G;
150793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float d_Y0B;
151793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float d_gammaR;                           /* Gamma values for the three guns */
152793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float d_gammaG;
153793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float d_gammaB;
154793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} TIFFDisplay;
155793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
156793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef struct {                                  /* YCbCr->RGB support */
157793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFFRGBValue* clamptab;                   /* range clamping table */
158793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int* Cr_r_tab;
159793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int* Cb_b_tab;
160793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int32* Cr_g_tab;
161793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int32* Cb_g_tab;
162793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int32* Y_tab;
163793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} TIFFYCbCrToRGB;
164793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
165793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef struct {                                  /* CIE Lab 1976->RGB support */
166793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int range;                                /* Size of conversion table */
167793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define CIELABTORGB_TABLE_RANGE 1500
168793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float rstep, gstep, bstep;
169793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float X0, Y0, Z0;                         /* Reference white point */
170793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFFDisplay display;
171793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float Yr2r[CIELABTORGB_TABLE_RANGE + 1];  /* Conversion of Yr to r */
172793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float Yg2g[CIELABTORGB_TABLE_RANGE + 1];  /* Conversion of Yg to g */
173793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float Yb2b[CIELABTORGB_TABLE_RANGE + 1];  /* Conversion of Yb to b */
174793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} TIFFCIELabToRGB;
175793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
176793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
177793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * RGBA-style image support.
178793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
179793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef struct _TIFFRGBAImage TIFFRGBAImage;
180793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
181793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * The image reading and conversion routines invoke
182793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * ``put routines'' to copy/image/whatever tiles of
183793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * raw image data.  A default set of routines are
184793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * provided to convert/copy raw image data to 8-bit
185793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * packed ABGR format rasters.  Applications can supply
186793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * alternate routines that unpack the data into a
187793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * different format or, for example, unpack the data
188793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * and draw the unpacked raster on the display.
189793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
190793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef void (*tileContigRoutine)
191793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
192793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    unsigned char*);
193793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef void (*tileSeparateRoutine)
194793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
195793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    unsigned char*, unsigned char*, unsigned char*, unsigned char*);
196793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
197793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * RGBA-reader state.
198793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
199793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerstruct _TIFFRGBAImage {
200793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFF* tif;                              /* image handle */
201793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int stoponerr;                          /* stop on read error */
202793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int isContig;                           /* data is packed/separate */
203793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int alpha;                              /* type of alpha data present */
204793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint32 width;                           /* image width */
205793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint32 height;                          /* image height */
206793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint16 bitspersample;                   /* image bits/sample */
207793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint16 samplesperpixel;                 /* image samples/pixel */
208793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint16 orientation;                     /* image orientation */
209793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint16 req_orientation;                 /* requested orientation */
210793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint16 photometric;                     /* image photometric interp */
211793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint16* redcmap;                        /* colormap pallete */
212793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint16* greencmap;
213793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint16* bluecmap;
214793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    /* get image data routine */
215793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
216793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    /* put decoded strip/tile */
217793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    union {
218793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        void (*any)(TIFFRGBAImage*);
219793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        tileContigRoutine contig;
220793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        tileSeparateRoutine separate;
221793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    } put;
222793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFFRGBValue* Map;                      /* sample mapping array */
223793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint32** BWmap;                         /* black&white map */
224793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint32** PALmap;                        /* palette image map */
225793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFFYCbCrToRGB* ycbcr;                  /* YCbCr conversion state */
226793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFFCIELabToRGB* cielab;                /* CIE L*a*b conversion state */
227793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
228793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint8* UaToAa;                          /* Unassociated alpha to associated alpha convertion LUT */
229793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint8* Bitdepth16To8;                   /* LUT for conversion from 16bit to 8bit values */
230793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
231793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int row_offset;
232793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int col_offset;
233793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler};
234793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
235793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
236793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Macros for extracting components from the
237793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * packed ABGR form returned by TIFFReadRGBAImage.
238793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
239793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFGetR(abgr) ((abgr) & 0xff)
240793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
241793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
242793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
243793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
244793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
245793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * A CODEC is a software package that implements decoding,
246793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * encoding, or decoding+encoding of a compression algorithm.
247793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * The library provides a collection of builtin codecs.
248793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * More codecs may be registered through calls to the library
249793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * and/or the builtin implementations may be overridden.
250793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
251793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef int (*TIFFInitMethod)(TIFF*, int);
252793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef struct {
253793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    char* name;
254793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint16 scheme;
255793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFFInitMethod init;
256793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} TIFFCodec;
257793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
258793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include <stdio.h>
259793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include <stdarg.h>
260793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
261793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/* share internal LogLuv conversion routines? */
262793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#ifndef LOGLUV_PUBLIC
263793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define LOGLUV_PUBLIC 1
264793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif
265793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
266793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#if !defined(__GNUC__) && !defined(__attribute__)
267793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#  define __attribute__(x) /*nothing*/
268793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif
269793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
270793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#if defined(c_plusplus) || defined(__cplusplus)
271793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern "C" {
272793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif
273793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef void (*TIFFErrorHandler)(const char*, const char*, va_list);
274793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list);
275793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t);
276793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
277793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef int (*TIFFCloseProc)(thandle_t);
278793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef toff_t (*TIFFSizeProc)(thandle_t);
279793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size);
280793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size);
281793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef void (*TIFFExtendProc)(TIFF*);
282793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
283793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern const char* TIFFGetVersion(void);
284793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
285793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern const TIFFCodec* TIFFFindCODEC(uint16);
286793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
287793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFUnRegisterCODEC(TIFFCodec*);
288793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFIsCODECConfigured(uint16);
289793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFCodec* TIFFGetConfiguredCODECs(void);
290793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
291793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
292793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Auxiliary functions.
293793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
294793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
295793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void* _TIFFmalloc(tmsize_t s);
296793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void* _TIFFrealloc(void* p, tmsize_t s);
297793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void _TIFFmemset(void* p, int v, tmsize_t c);
298793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);
299793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c);
300793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void _TIFFfree(void* p);
301793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
302793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
303793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler** Stuff, related to tag handling and creating custom tags.
304793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler*/
305793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFGetTagListCount( TIFF * );
306793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 TIFFGetTagListEntry( TIFF *, int tag_index );
307793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
308793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFF_ANY       TIFF_NOTYPE     /* for field descriptor searching */
309793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFF_VARIABLE  -1              /* marker for variable length tags */
310793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFF_SPP       -2              /* marker for SamplesPerPixel tags */
311793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define TIFF_VARIABLE2 -3              /* marker for uint32 var-length tags */
312793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
313793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define FIELD_CUSTOM    65
314793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
315793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef struct _TIFFField TIFFField;
316793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef struct _TIFFFieldArray TIFFFieldArray;
317793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
318793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType);
319793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern const TIFFField* TIFFFieldWithTag(TIFF*, uint32);
320793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern const TIFFField* TIFFFieldWithName(TIFF*, const char *);
321793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
322793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list);
323793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list);
324793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef void (*TIFFPrintMethod)(TIFF*, FILE*, long);
325793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
326793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef struct {
327793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFFVSetMethod vsetfield; /* tag set routine */
328793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFFVGetMethod vgetfield; /* tag get routine */
329793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFFPrintMethod printdir; /* directory print routine */
330793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} TIFFTagMethods;
331793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
332793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern  TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
333793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern  void *TIFFGetClientInfo(TIFF *, const char *);
334793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern  void TIFFSetClientInfo(TIFF *, void *, const char *);
335793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
336793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFCleanup(TIFF* tif);
337793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFClose(TIFF* tif);
338793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFFlush(TIFF* tif);
339793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFFlushData(TIFF* tif);
340793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFGetField(TIFF* tif, uint32 tag, ...);
341793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap);
342793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...);
343793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap);
344793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadDirectory(TIFF* tif);
345793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray);
346793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff);
347793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint64 TIFFScanlineSize64(TIFF* tif);
348793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFScanlineSize(TIFF* tif);
349793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint64 TIFFRasterScanlineSize64(TIFF* tif);
350793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFRasterScanlineSize(TIFF* tif);
351793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint64 TIFFStripSize64(TIFF* tif);
352793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFStripSize(TIFF* tif);
353793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip);
354793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip);
355793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows);
356793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows);
357793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint64 TIFFTileRowSize64(TIFF* tif);
358793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFTileRowSize(TIFF* tif);
359793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint64 TIFFTileSize64(TIFF* tif);
360793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFTileSize(TIFF* tif);
361793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows);
362793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows);
363793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request);
364793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
365793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFFileno(TIFF*);
366793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFSetFileno(TIFF*, int);
367793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern thandle_t TIFFClientdata(TIFF*);
368793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern thandle_t TIFFSetClientdata(TIFF*, thandle_t);
369793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFGetMode(TIFF*);
370793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFSetMode(TIFF*, int);
371793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFIsTiled(TIFF*);
372793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFIsByteSwapped(TIFF*);
373793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFIsUpSampled(TIFF*);
374793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFIsMSB2LSB(TIFF*);
375793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFIsBigEndian(TIFF*);
376793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFReadWriteProc TIFFGetReadProc(TIFF*);
377793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFReadWriteProc TIFFGetWriteProc(TIFF*);
378793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFSeekProc TIFFGetSeekProc(TIFF*);
379793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFCloseProc TIFFGetCloseProc(TIFF*);
380793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFSizeProc TIFFGetSizeProc(TIFF*);
381793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFMapFileProc TIFFGetMapFileProc(TIFF*);
382793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*);
383793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 TIFFCurrentRow(TIFF*);
384793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint16 TIFFCurrentDirectory(TIFF*);
385793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint16 TIFFNumberOfDirectories(TIFF*);
386793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint64 TIFFCurrentDirOffset(TIFF*);
387793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 TIFFCurrentStrip(TIFF*);
388793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 TIFFCurrentTile(TIFF* tif);
389793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size);
390793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size);
391793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFSetupStrips(TIFF *);
392793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFWriteCheck(TIFF*, int, const char *);
393793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFFreeDirectory(TIFF*);
394793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFCreateDirectory(TIFF*);
395793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*);
396793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFCreateEXIFDirectory(TIFF*);
397793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFLastDirectory(TIFF*);
398793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFSetDirectory(TIFF*, uint16);
399793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFSetSubDirectory(TIFF*, uint64);
400793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFUnlinkDirectory(TIFF*, uint16);
401793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFSetField(TIFF*, uint32, ...);
402793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFVSetField(TIFF*, uint32, va_list);
403793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFUnsetField(TIFF*, uint32);
404793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFWriteDirectory(TIFF *);
405793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFWriteCustomDirectory(TIFF *, uint64 *);
406793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFCheckpointDirectory(TIFF *);
407793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFRewriteDirectory(TIFF *);
408793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
409793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#if defined(c_plusplus) || defined(__cplusplus)
410793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
411793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
412793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
413793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
414793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*,
415793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    int = ORIENTATION_BOTLEFT, int = 0);
416793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#else
417793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFPrintDirectory(TIFF*, FILE*, long);
418793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
419793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
420793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
421793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int);
422793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif
423793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
424793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * );
425793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
426793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFRGBAImageOK(TIFF*, char [1024]);
427793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
428793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
429793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFRGBAImageEnd(TIFFRGBAImage*);
430793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFF* TIFFOpen(const char*, const char*);
431793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler# ifdef __WIN32__
432793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFF* TIFFOpenW(const wchar_t*, const char*);
433793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler# endif /* __WIN32__ */
434793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFF* TIFFFdOpen(int, const char*, const char*);
435793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFF* TIFFClientOpen(const char*, const char*,
436793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        thandle_t,
437793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        TIFFReadWriteProc, TIFFReadWriteProc,
438793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        TIFFSeekProc, TIFFCloseProc,
439793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        TIFFSizeProc,
440793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        TIFFMapFileProc, TIFFUnmapFileProc);
441793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern const char* TIFFFileName(TIFF*);
442793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern const char* TIFFSetFileName(TIFF*, const char *);
443793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3)));
444793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4)));
445793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3)));
446793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4)));
447793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
448793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
449793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
450793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
451793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
452793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
453793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
454793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 TIFFNumberOfTiles(TIFF*);
455793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
456793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
457793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 TIFFComputeStrip(TIFF*, uint32, uint16);
458793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 TIFFNumberOfStrips(TIFF*);
459793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
460793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
461793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
462793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
463793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
464793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
465793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
466793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
467793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFDataWidth(TIFFDataType);    /* table of tag datatype widths */
468793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSetWriteOffset(TIFF* tif, toff_t off);
469793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabShort(uint16*);
470793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabLong(uint32*);
471793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabLong8(uint64*);
472793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabFloat(float*);
473793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabDouble(double*);
474793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n);
475793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n);
476793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n);
477793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n);
478793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n);
479793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n);
480793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFReverseBits(uint8* cp, tmsize_t n);
481793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern const unsigned char* TIFFGetBitRevTable(int);
482793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
483793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#ifdef LOGLUV_PUBLIC
484793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define U_NEU		0.210526316
485793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define V_NEU		0.473684211
486793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define UVSCALE		410.
487793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern double LogL16toY(int);
488793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern double LogL10toY(int);
489793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void XYZtoRGB24(float*, uint8*);
490793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int uv_decode(double*, double*, int);
491793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void LogLuv24toXYZ(uint32, float*);
492793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void LogLuv32toXYZ(uint32, float*);
493793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#if defined(c_plusplus) || defined(__cplusplus)
494793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
495793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
496793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
497793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER);
498793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER);
499793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#else
500793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int LogL16fromY(double, int);
501793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int LogL10fromY(double, int);
502793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int uv_encode(double, double, int);
503793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 LogLuv24fromXYZ(float*, int);
504793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern uint32 LogLuv32fromXYZ(float*, int);
505793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif
506793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif /* LOGLUV_PUBLIC */
507793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
508793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*);
509793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32,
510793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    float *, float *, float *);
511793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float,
512793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint32 *, uint32 *, uint32 *);
513793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
514793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*);
515793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
516793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    uint32 *, uint32 *, uint32 *);
517793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
518793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/****************************************************************************
519793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *               O B S O L E T E D    I N T E R F A C E S
520793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
521793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Don't use this stuff in your applications, it may be removed in the future
522793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * libtiff versions.
523793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler ****************************************************************************/
524793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef	struct {
525793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    ttag_t	field_tag;		/* field's tag */
526793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    short	field_readcount;	/* read count/TIFF_VARIABLE/TIFF_SPP */
527793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    short	field_writecount;	/* write count/TIFF_VARIABLE */
528793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TIFFDataType field_type;	/* type of associated data */
529793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        unsigned short field_bit;	/* bit in fieldsset bit vector */
530793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    unsigned char field_oktochange;	/* if true, can change while writing */
531793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    unsigned char field_passcount;	/* if true, pass dir count on set */
532793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    char	*field_name;		/* ASCII name */
533793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler} TIFFFieldInfo;
534793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
535793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerextern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32);
536793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
537793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#if defined(c_plusplus) || defined(__cplusplus)
538793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler}
539793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif
540793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
541793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif /* _TIFFIO_ */
542793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
543793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/* vim: set ts=8 sts=8 sw=8 noet: */
544793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
545793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Local Variables:
546793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * mode: c
547793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * c-basic-offset: 8
548793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * fill-column: 78
549793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * End:
550793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
551