CW fix, added tif_color
[wxWidgets.git] / src / tiff / tif_dir.h
1 /* $Header$ */
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 /*
34 * Internal format of a TIFF directory entry.
35 */
36 typedef struct {
37 #define FIELD_SETLONGS 4
38 /* bit vector of fields that are set */
39 u_long td_fieldsset[FIELD_SETLONGS];
40
41 uint32 td_imagewidth, td_imagelength, td_imagedepth;
42 uint32 td_tilewidth, td_tilelength, td_tiledepth;
43 uint32 td_subfiletype;
44 uint16 td_bitspersample;
45 uint16 td_sampleformat;
46 uint16 td_compression;
47 uint16 td_photometric;
48 uint16 td_threshholding;
49 uint16 td_fillorder;
50 uint16 td_orientation;
51 uint16 td_samplesperpixel;
52 uint32 td_rowsperstrip;
53 uint16 td_minsamplevalue, td_maxsamplevalue;
54 double td_sminsamplevalue, td_smaxsamplevalue;
55 float td_xresolution, td_yresolution;
56 uint16 td_resolutionunit;
57 uint16 td_planarconfig;
58 float td_xposition, td_yposition;
59 uint16 td_pagenumber[2];
60 uint16* td_colormap[3];
61 uint16 td_halftonehints[2];
62 uint16 td_extrasamples;
63 uint16* td_sampleinfo;
64 double td_stonits;
65 char* td_documentname;
66 char* td_artist;
67 char* td_datetime;
68 char* td_hostcomputer;
69 char* td_imagedescription;
70 char* td_make;
71 char* td_model;
72 char* td_copyright;
73 char* td_pagename;
74 tstrip_t td_stripsperimage;
75 tstrip_t td_nstrips; /* size of offset & bytecount arrays */
76 uint32* td_stripoffset;
77 uint32* td_stripbytecount;
78 #if SUBIFD_SUPPORT
79 uint16 td_nsubifd;
80 uint32* td_subifd;
81 #endif
82 #ifdef YCBCR_SUPPORT
83 float* td_ycbcrcoeffs;
84 uint16 td_ycbcrsubsampling[2];
85 uint16 td_ycbcrpositioning;
86 #endif
87 #ifdef COLORIMETRY_SUPPORT
88 float* td_whitepoint;
89 float* td_primarychromas;
90 float* td_refblackwhite;
91 uint16* td_transferfunction[3];
92 #endif
93 #ifdef CMYK_SUPPORT
94 uint16 td_inkset;
95 uint16 td_ninks;
96 uint16 td_dotrange[2];
97 int td_inknameslen;
98 char* td_inknames;
99 char* td_targetprinter;
100 #endif
101 #ifdef ICC_SUPPORT
102 uint32 td_profileLength;
103 void *td_profileData;
104 #endif
105 #ifdef PHOTOSHOP_SUPPORT
106 uint32 td_photoshopLength;
107 void *td_photoshopData;
108 #endif
109 #ifdef IPTC_SUPPORT
110 uint32 td_richtiffiptcLength;
111 void *td_richtiffiptcData;
112 #endif
113 /* Begin Pixar Tag values. */
114 uint32 td_imagefullwidth, td_imagefulllength;
115 char* td_textureformat;
116 char* td_wrapmodes;
117 float td_fovcot;
118 float* td_matrixWorldToScreen;
119 float* td_matrixWorldToCamera;
120 /* End Pixar Tag Values. */
121 uint32 td_xmlpacketLength;
122 void *td_xmlpacketData;
123 int td_customValueCount;
124 TIFFTagValue *td_customValues;
125 } TIFFDirectory;
126
127 /*
128 * Field flags used to indicate fields that have
129 * been set in a directory, and to reference fields
130 * when manipulating a directory.
131 */
132
133 /*
134 * FIELD_IGNORE is used to signify tags that are to
135 * be processed but otherwise ignored. This permits
136 * antiquated tags to be quietly read and discarded.
137 * Note that a bit *is* allocated for ignored tags;
138 * this is understood by the directory reading logic
139 * which uses this fact to avoid special-case handling
140 */
141 #define FIELD_IGNORE 0
142
143 /* multi-item fields */
144 #define FIELD_IMAGEDIMENSIONS 1
145 #define FIELD_TILEDIMENSIONS 2
146 #define FIELD_RESOLUTION 3
147 #define FIELD_POSITION 4
148
149 /* single-item fields */
150 #define FIELD_SUBFILETYPE 5
151 #define FIELD_BITSPERSAMPLE 6
152 #define FIELD_COMPRESSION 7
153 #define FIELD_PHOTOMETRIC 8
154 #define FIELD_THRESHHOLDING 9
155 #define FIELD_FILLORDER 10
156 #define FIELD_DOCUMENTNAME 11
157 #define FIELD_IMAGEDESCRIPTION 12
158 #define FIELD_MAKE 13
159 #define FIELD_MODEL 14
160 #define FIELD_ORIENTATION 15
161 #define FIELD_SAMPLESPERPIXEL 16
162 #define FIELD_ROWSPERSTRIP 17
163 #define FIELD_MINSAMPLEVALUE 18
164 #define FIELD_MAXSAMPLEVALUE 19
165 #define FIELD_PLANARCONFIG 20
166 #define FIELD_PAGENAME 21
167 #define FIELD_RESOLUTIONUNIT 22
168 #define FIELD_PAGENUMBER 23
169 #define FIELD_STRIPBYTECOUNTS 24
170 #define FIELD_STRIPOFFSETS 25
171 #define FIELD_COLORMAP 26
172 #define FIELD_ARTIST 27
173 #define FIELD_DATETIME 28
174 #define FIELD_HOSTCOMPUTER 29
175 /* unused - was FIELD_SOFTWARE 30 */
176 #define FIELD_EXTRASAMPLES 31
177 #define FIELD_SAMPLEFORMAT 32
178 #define FIELD_SMINSAMPLEVALUE 33
179 #define FIELD_SMAXSAMPLEVALUE 34
180 #define FIELD_IMAGEDEPTH 35
181 #define FIELD_TILEDEPTH 36
182 #define FIELD_HALFTONEHINTS 37
183 #define FIELD_YCBCRCOEFFICIENTS 38
184 #define FIELD_YCBCRSUBSAMPLING 39
185 #define FIELD_YCBCRPOSITIONING 40
186 #define FIELD_REFBLACKWHITE 41
187 #define FIELD_WHITEPOINT 42
188 #define FIELD_PRIMARYCHROMAS 43
189 #define FIELD_TRANSFERFUNCTION 44
190 #define FIELD_INKSET 45
191 #define FIELD_INKNAMES 46
192 #define FIELD_DOTRANGE 47
193 #define FIELD_TARGETPRINTER 48
194 #define FIELD_SUBIFD 49
195 #define FIELD_NUMBEROFINKS 50
196 #define FIELD_ICCPROFILE 51
197 #define FIELD_PHOTOSHOP 52
198 #define FIELD_RICHTIFFIPTC 53
199 #define FIELD_STONITS 54
200 /* Begin PIXAR */
201 #define FIELD_IMAGEFULLWIDTH 55
202 #define FIELD_IMAGEFULLLENGTH 56
203 #define FIELD_TEXTUREFORMAT 57
204 #define FIELD_WRAPMODES 58
205 #define FIELD_FOVCOT 59
206 #define FIELD_MATRIX_WORLDTOSCREEN 60
207 #define FIELD_MATRIX_WORLDTOCAMERA 61
208 #define FIELD_COPYRIGHT 62
209 #define FIELD_XMLPACKET 63
210 /* FIELD_CUSTOM (see tiffio.h) 65 */
211 /* end of support for well-known tags; codec-private tags follow */
212 #define FIELD_CODEC 66 /* base of codec-private tags */
213
214
215 /*
216 * Pseudo-tags don't normally need field bits since they
217 * are not written to an output file (by definition).
218 * The library also has express logic to always query a
219 * codec for a pseudo-tag so allocating a field bit for
220 * one is a waste. If codec wants to promote the notion
221 * of a pseudo-tag being ``set'' or ``unset'' then it can
222 * do using internal state flags without polluting the
223 * field bit space defined for real tags.
224 */
225 #define FIELD_PSEUDO 0
226
227 #define FIELD_LAST (32*FIELD_SETLONGS-1)
228
229 #define TIFFExtractData(tif, type, v) \
230 ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
231 ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \
232 (v) & (tif)->tif_typemask[type]))
233 #define TIFFInsertData(tif, type, v) \
234 ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
235 ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \
236 (v) & (tif)->tif_typemask[type]))
237
238
239 #define BITn(n) (((u_long)1L)<<((n)&0x1f))
240 #define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32])
241 #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
242 #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
243 #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
244
245 #define FieldSet(fields, f) (fields[(f)/32] & BITn(f))
246 #define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f))
247
248 #if defined(__cplusplus)
249 extern "C" {
250 #endif
251 extern void _TIFFSetupFieldInfo(TIFF*);
252 extern void _TIFFPrintFieldInfo(TIFF*, FILE*);
253 extern TIFFDataType _TIFFSampleToTagType(TIFF*);
254 extern const TIFFFieldInfo* _TIFFFindOrRegisterFieldInfo( TIFF *tif,
255 ttag_t tag,
256 TIFFDataType dt );
257 extern TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag,
258 TIFFDataType dt );
259
260 #define _TIFFMergeFieldInfo TIFFMergeFieldInfo
261 #define _TIFFFindFieldInfo TIFFFindFieldInfo
262 #define _TIFFFieldWithTag TIFFFieldWithTag
263
264 #if defined(__cplusplus)
265 }
266 #endif
267 #endif /* _TIFFDIR_ */