]> git.saurik.com Git - wxWidgets.git/blob - src/tiff/tif_dir.h
Various changes to make pop up menus work
[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 3
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_software;
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 } TIFFDirectory;
114
115 /*
116 * Field flags used to indicate fields that have
117 * been set in a directory, and to reference fields
118 * when manipulating a directory.
119 */
120
121 /*
122 * FIELD_IGNORE is used to signify tags that are to
123 * be processed but otherwise ignored. This permits
124 * antiquated tags to be quietly read and discarded.
125 * Note that a bit *is* allocated for ignored tags;
126 * this is understood by the directory reading logic
127 * which uses this fact to avoid special-case handling
128 */
129 #define FIELD_IGNORE 0
130
131 /* multi-item fields */
132 #define FIELD_IMAGEDIMENSIONS 1
133 #define FIELD_TILEDIMENSIONS 2
134 #define FIELD_RESOLUTION 3
135 #define FIELD_POSITION 4
136
137 /* single-item fields */
138 #define FIELD_SUBFILETYPE 5
139 #define FIELD_BITSPERSAMPLE 6
140 #define FIELD_COMPRESSION 7
141 #define FIELD_PHOTOMETRIC 8
142 #define FIELD_THRESHHOLDING 9
143 #define FIELD_FILLORDER 10
144 #define FIELD_DOCUMENTNAME 11
145 #define FIELD_IMAGEDESCRIPTION 12
146 #define FIELD_MAKE 13
147 #define FIELD_MODEL 14
148 #define FIELD_ORIENTATION 15
149 #define FIELD_SAMPLESPERPIXEL 16
150 #define FIELD_ROWSPERSTRIP 17
151 #define FIELD_MINSAMPLEVALUE 18
152 #define FIELD_MAXSAMPLEVALUE 19
153 #define FIELD_PLANARCONFIG 20
154 #define FIELD_PAGENAME 21
155 #define FIELD_RESOLUTIONUNIT 22
156 #define FIELD_PAGENUMBER 23
157 #define FIELD_STRIPBYTECOUNTS 24
158 #define FIELD_STRIPOFFSETS 25
159 #define FIELD_COLORMAP 26
160 #define FIELD_ARTIST 27
161 #define FIELD_DATETIME 28
162 #define FIELD_HOSTCOMPUTER 29
163 #define FIELD_SOFTWARE 30
164 #define FIELD_EXTRASAMPLES 31
165 #define FIELD_SAMPLEFORMAT 32
166 #define FIELD_SMINSAMPLEVALUE 33
167 #define FIELD_SMAXSAMPLEVALUE 34
168 #define FIELD_IMAGEDEPTH 35
169 #define FIELD_TILEDEPTH 36
170 #define FIELD_HALFTONEHINTS 37
171 #define FIELD_YCBCRCOEFFICIENTS 38
172 #define FIELD_YCBCRSUBSAMPLING 39
173 #define FIELD_YCBCRPOSITIONING 40
174 #define FIELD_REFBLACKWHITE 41
175 #define FIELD_WHITEPOINT 42
176 #define FIELD_PRIMARYCHROMAS 43
177 #define FIELD_TRANSFERFUNCTION 44
178 #define FIELD_INKSET 45
179 #define FIELD_INKNAMES 46
180 #define FIELD_DOTRANGE 47
181 #define FIELD_TARGETPRINTER 48
182 #define FIELD_SUBIFD 49
183 #define FIELD_NUMBEROFINKS 50
184 #define FIELD_ICCPROFILE 51
185 #define FIELD_PHOTOSHOP 52
186 #define FIELD_RICHTIFFIPTC 53
187 #define FIELD_STONITS 54
188 /* end of support for well-known tags; codec-private tags follow */
189 #define FIELD_CODEC 55 /* base of codec-private tags */
190 /*
191 * Pseudo-tags don't normally need field bits since they
192 * are not written to an output file (by definition).
193 * The library also has express logic to always query a
194 * codec for a pseudo-tag so allocating a field bit for
195 * one is a waste. If codec wants to promote the notion
196 * of a pseudo-tag being ``set'' or ``unset'' then it can
197 * do using internal state flags without polluting the
198 * field bit space defined for real tags.
199 */
200 #define FIELD_PSEUDO 0
201
202 #define FIELD_LAST (32*FIELD_SETLONGS-1)
203
204 #define TIFFExtractData(tif, type, v) \
205 ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
206 ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \
207 (v) & (tif)->tif_typemask[type]))
208 #define TIFFInsertData(tif, type, v) \
209 ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
210 ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \
211 (v) & (tif)->tif_typemask[type]))
212
213 typedef struct {
214 ttag_t field_tag; /* field's tag */
215 short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
216 short field_writecount; /* write count/TIFF_VARIABLE */
217 TIFFDataType field_type; /* type of associated data */
218 u_short field_bit; /* bit in fieldsset bit vector */
219 u_char field_oktochange; /* if true, can change while writing */
220 u_char field_passcount; /* if true, pass dir count on set */
221 char *field_name; /* ASCII name */
222 } TIFFFieldInfo;
223
224 #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
225 #define TIFF_VARIABLE -1 /* marker for variable length tags */
226 #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */
227 #define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */
228
229 extern const int tiffDataWidth[]; /* table of tag datatype widths */
230
231 #define BITn(n) (((u_long)1L)<<((n)&0x1f))
232 #define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32])
233 #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
234 #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
235 #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
236
237 #define FieldSet(fields, f) (fields[(f)/32] & BITn(f))
238 #define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f))
239
240 #if defined(__cplusplus)
241 extern "C" {
242 #endif
243 extern void _TIFFSetupFieldInfo(TIFF*);
244 extern void _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int);
245 extern void _TIFFPrintFieldInfo(TIFF*, FILE*);
246 extern const TIFFFieldInfo* _TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType);
247 extern const TIFFFieldInfo* _TIFFFieldWithTag(TIFF*, ttag_t);
248 extern TIFFDataType _TIFFSampleToTagType(TIFF*);
249 #if defined(__cplusplus)
250 }
251 #endif
252 #endif /* _TIFFDIR_ */