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