]> git.saurik.com Git - wxWidgets.git/blame - src/tiff/libtiff/tif_dir.h
Compilation fix for wxMSW with wxUSE_MSGBOX_HOOK==0.
[wxWidgets.git] / src / tiff / libtiff / tif_dir.h
CommitLineData
8414a40c
VZ
1
2/*
3 * Copyright (c) 1988-1997 Sam Leffler
4 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that (i) the above copyright notices and this permission notice appear in
9 * all copies of the software and related documentation, and (ii) the names of
10 * Sam Leffler and Silicon Graphics may not be used in any advertising or
11 * publicity relating to the software without the specific, prior written
12 * permission of Sam Leffler and Silicon Graphics.
13 *
14 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17 *
18 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
19 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 * OF THIS SOFTWARE.
24 */
25
26#ifndef _TIFFDIR_
27#define _TIFFDIR_
28/*
29 * ``Library-private'' Directory-related Definitions.
30 */
31
80ed523f
VZ
32typedef struct {
33 const TIFFField *info;
34 int count;
35 void *value;
36} TIFFTagValue;
37
38/*
39 * TIFF Image File Directories are comprised of a table of field
40 * descriptors of the form shown below. The table is sorted in
41 * ascending order by tag. The values associated with each entry are
42 * disjoint and may appear anywhere in the file (so long as they are
43 * placed on a word boundary).
44 *
45 * If the value is 4 bytes or less, in ClassicTIFF, or 8 bytes or less in
46 * BigTIFF, then it is placed in the offset field to save space. If so,
47 * it is left-justified in the offset field.
48 */
49typedef struct {
50 uint16 tdir_tag; /* see below */
51 uint16 tdir_type; /* data type; see below */
52 uint64 tdir_count; /* number of items; length in spec */
53 union {
54 uint16 toff_short;
55 uint32 toff_long;
56 uint64 toff_long8;
57 } tdir_offset; /* either offset or the data itself if fits */
58} TIFFDirEntry;
59
8414a40c
VZ
60/*
61 * Internal format of a TIFF directory entry.
62 */
80ed523f
VZ
63typedef struct {
64#define FIELD_SETLONGS 4
8414a40c 65 /* bit vector of fields that are set */
80ed523f
VZ
66 unsigned long td_fieldsset[FIELD_SETLONGS];
67
68 uint32 td_imagewidth, td_imagelength, td_imagedepth;
69 uint32 td_tilewidth, td_tilelength, td_tiledepth;
70 uint32 td_subfiletype;
71 uint16 td_bitspersample;
72 uint16 td_sampleformat;
73 uint16 td_compression;
74 uint16 td_photometric;
75 uint16 td_threshholding;
76 uint16 td_fillorder;
77 uint16 td_orientation;
78 uint16 td_samplesperpixel;
79 uint32 td_rowsperstrip;
80 uint16 td_minsamplevalue, td_maxsamplevalue;
81 double* td_sminsamplevalue;
82 double* td_smaxsamplevalue;
83 float td_xresolution, td_yresolution;
84 uint16 td_resolutionunit;
85 uint16 td_planarconfig;
86 float td_xposition, td_yposition;
87 uint16 td_pagenumber[2];
88 uint16* td_colormap[3];
89 uint16 td_halftonehints[2];
90 uint16 td_extrasamples;
91 uint16* td_sampleinfo;
92 /* even though the name is misleading, td_stripsperimage is the number
93 * of striles (=strips or tiles) per plane, and td_nstrips the total
94 * number of striles */
95 uint32 td_stripsperimage;
96 uint32 td_nstrips; /* size of offset & bytecount arrays */
97 uint64* td_stripoffset;
98 uint64* td_stripbytecount;
99 int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
100#if defined(DEFER_STRILE_LOAD)
101 TIFFDirEntry td_stripoffset_entry; /* for deferred loading */
102 TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */
103#endif
104 uint16 td_nsubifd;
105 uint64* td_subifd;
8414a40c 106 /* YCbCr parameters */
80ed523f
VZ
107 uint16 td_ycbcrsubsampling[2];
108 uint16 td_ycbcrpositioning;
8414a40c 109 /* Colorimetry parameters */
80ed523f
VZ
110 uint16* td_transferfunction[3];
111 float* td_refblackwhite;
8414a40c 112 /* CMYK parameters */
80ed523f
VZ
113 int td_inknameslen;
114 char* td_inknames;
8414a40c
VZ
115
116 int td_customValueCount;
117 TIFFTagValue *td_customValues;
118} TIFFDirectory;
119
120/*
80ed523f
VZ
121 * Field flags used to indicate fields that have been set in a directory, and
122 * to reference fields when manipulating a directory.
8414a40c
VZ
123 */
124
125/*
80ed523f
VZ
126 * FIELD_IGNORE is used to signify tags that are to be processed but otherwise
127 * ignored. This permits antiquated tags to be quietly read and discarded.
128 * Note that a bit *is* allocated for ignored tags; this is understood by the
129 * directory reading logic which uses this fact to avoid special-case handling
130 */
131#define FIELD_IGNORE 0
8414a40c
VZ
132
133/* multi-item fields */
80ed523f
VZ
134#define FIELD_IMAGEDIMENSIONS 1
135#define FIELD_TILEDIMENSIONS 2
136#define FIELD_RESOLUTION 3
137#define FIELD_POSITION 4
8414a40c
VZ
138
139/* single-item fields */
80ed523f
VZ
140#define FIELD_SUBFILETYPE 5
141#define FIELD_BITSPERSAMPLE 6
142#define FIELD_COMPRESSION 7
143#define FIELD_PHOTOMETRIC 8
144#define FIELD_THRESHHOLDING 9
145#define FIELD_FILLORDER 10
146#define FIELD_ORIENTATION 15
147#define FIELD_SAMPLESPERPIXEL 16
148#define FIELD_ROWSPERSTRIP 17
149#define FIELD_MINSAMPLEVALUE 18
150#define FIELD_MAXSAMPLEVALUE 19
151#define FIELD_PLANARCONFIG 20
152#define FIELD_RESOLUTIONUNIT 22
153#define FIELD_PAGENUMBER 23
154#define FIELD_STRIPBYTECOUNTS 24
155#define FIELD_STRIPOFFSETS 25
156#define FIELD_COLORMAP 26
157#define FIELD_EXTRASAMPLES 31
158#define FIELD_SAMPLEFORMAT 32
159#define FIELD_SMINSAMPLEVALUE 33
160#define FIELD_SMAXSAMPLEVALUE 34
161#define FIELD_IMAGEDEPTH 35
162#define FIELD_TILEDEPTH 36
163#define FIELD_HALFTONEHINTS 37
164#define FIELD_YCBCRSUBSAMPLING 39
165#define FIELD_YCBCRPOSITIONING 40
166#define FIELD_REFBLACKWHITE 41
167#define FIELD_TRANSFERFUNCTION 44
168#define FIELD_INKNAMES 46
169#define FIELD_SUBIFD 49
170/* FIELD_CUSTOM (see tiffio.h) 65 */
8414a40c 171/* end of support for well-known tags; codec-private tags follow */
80ed523f 172#define FIELD_CODEC 66 /* base of codec-private tags */
8414a40c
VZ
173
174
175/*
80ed523f
VZ
176 * Pseudo-tags don't normally need field bits since they are not written to an
177 * output file (by definition). The library also has express logic to always
178 * query a codec for a pseudo-tag so allocating a field bit for one is a
179 * waste. If codec wants to promote the notion of a pseudo-tag being ``set''
180 * or ``unset'' then it can do using internal state flags without polluting
181 * the field bit space defined for real tags.
8414a40c 182 */
80ed523f 183#define FIELD_PSEUDO 0
8414a40c 184
80ed523f 185#define FIELD_LAST (32*FIELD_SETLONGS-1)
8414a40c 186
80ed523f
VZ
187#define BITn(n) (((unsigned long)1L)<<((n)&0x1f))
188#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32])
189#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
8414a40c
VZ
190#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
191#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
192
80ed523f
VZ
193#define FieldSet(fields, f) (fields[(f)/32] & BITn(f))
194#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f))
195
196typedef enum {
197 TIFF_SETGET_UNDEFINED = 0,
198 TIFF_SETGET_ASCII = 1,
199 TIFF_SETGET_UINT8 = 2,
200 TIFF_SETGET_SINT8 = 3,
201 TIFF_SETGET_UINT16 = 4,
202 TIFF_SETGET_SINT16 = 5,
203 TIFF_SETGET_UINT32 = 6,
204 TIFF_SETGET_SINT32 = 7,
205 TIFF_SETGET_UINT64 = 8,
206 TIFF_SETGET_SINT64 = 9,
207 TIFF_SETGET_FLOAT = 10,
208 TIFF_SETGET_DOUBLE = 11,
209 TIFF_SETGET_IFD8 = 12,
210 TIFF_SETGET_INT = 13,
211 TIFF_SETGET_UINT16_PAIR = 14,
212 TIFF_SETGET_C0_ASCII = 15,
213 TIFF_SETGET_C0_UINT8 = 16,
214 TIFF_SETGET_C0_SINT8 = 17,
215 TIFF_SETGET_C0_UINT16 = 18,
216 TIFF_SETGET_C0_SINT16 = 19,
217 TIFF_SETGET_C0_UINT32 = 20,
218 TIFF_SETGET_C0_SINT32 = 21,
219 TIFF_SETGET_C0_UINT64 = 22,
220 TIFF_SETGET_C0_SINT64 = 23,
221 TIFF_SETGET_C0_FLOAT = 24,
222 TIFF_SETGET_C0_DOUBLE = 25,
223 TIFF_SETGET_C0_IFD8 = 26,
224 TIFF_SETGET_C16_ASCII = 27,
225 TIFF_SETGET_C16_UINT8 = 28,
226 TIFF_SETGET_C16_SINT8 = 29,
227 TIFF_SETGET_C16_UINT16 = 30,
228 TIFF_SETGET_C16_SINT16 = 31,
229 TIFF_SETGET_C16_UINT32 = 32,
230 TIFF_SETGET_C16_SINT32 = 33,
231 TIFF_SETGET_C16_UINT64 = 34,
232 TIFF_SETGET_C16_SINT64 = 35,
233 TIFF_SETGET_C16_FLOAT = 36,
234 TIFF_SETGET_C16_DOUBLE = 37,
235 TIFF_SETGET_C16_IFD8 = 38,
236 TIFF_SETGET_C32_ASCII = 39,
237 TIFF_SETGET_C32_UINT8 = 40,
238 TIFF_SETGET_C32_SINT8 = 41,
239 TIFF_SETGET_C32_UINT16 = 42,
240 TIFF_SETGET_C32_SINT16 = 43,
241 TIFF_SETGET_C32_UINT32 = 44,
242 TIFF_SETGET_C32_SINT32 = 45,
243 TIFF_SETGET_C32_UINT64 = 46,
244 TIFF_SETGET_C32_SINT64 = 47,
245 TIFF_SETGET_C32_FLOAT = 48,
246 TIFF_SETGET_C32_DOUBLE = 49,
247 TIFF_SETGET_C32_IFD8 = 50,
248 TIFF_SETGET_OTHER = 51
249} TIFFSetGetFieldType;
8414a40c
VZ
250
251#if defined(__cplusplus)
252extern "C" {
253#endif
80ed523f
VZ
254
255extern const TIFFFieldArray* _TIFFGetFields(void);
256extern const TIFFFieldArray* _TIFFGetExifFields(void);
257extern void _TIFFSetupFields(TIFF* tif, const TIFFFieldArray* infoarray);
258extern void _TIFFPrintFieldInfo(TIFF*, FILE*);
259
260extern int _TIFFFillStriles(TIFF*);
261
262typedef enum {
263 tfiatImage,
264 tfiatExif,
265 tfiatOther
266} TIFFFieldArrayType;
267
268struct _TIFFFieldArray {
269 TIFFFieldArrayType type; /* array type, will be used to determine if IFD is image and such */
270 uint32 allocated_size; /* 0 if array is constant, other if modified by future definition extension support */
271 uint32 count; /* number of elements in fields array */
272 TIFFField* fields; /* actual field info */
273};
274
275struct _TIFFField {
276 uint32 field_tag; /* field's tag */
277 short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
278 short field_writecount; /* write count/TIFF_VARIABLE */
279 TIFFDataType field_type; /* type of associated data */
280 uint32 reserved; /* reserved for future extension */
281 TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField */
282 TIFFSetGetFieldType get_field_type; /* type to be passed to TIFFGetField */
283 unsigned short field_bit; /* bit in fieldsset bit vector */
284 unsigned char field_oktochange; /* if true, can change while writing */
285 unsigned char field_passcount; /* if true, pass dir count on set */
286 char* field_name; /* ASCII name */
287 TIFFFieldArray* field_subfields; /* if field points to child ifds, child ifd field definition array */
288};
289
290extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32);
291extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType);
292extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32, TIFFDataType);
8414a40c
VZ
293
294#if defined(__cplusplus)
295}
296#endif
297#endif /* _TIFFDIR_ */
298
299/* vim: set ts=8 sts=8 sw=8 noet: */
80ed523f
VZ
300
301/*
302 * Local Variables:
303 * mode: c
304 * c-basic-offset: 8
305 * fill-column: 78
306 * End:
307 */