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