File: tif_dir.h

package info (click to toggle)
vtk 5.0.4-1.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 51,084 kB
  • ctags: 70,426
  • sloc: cpp: 524,166; ansic: 220,276; tcl: 43,377; python: 14,037; perl: 3,102; java: 1,436; yacc: 1,033; sh: 339; lex: 248; makefile: 197; asm: 154
file content (282 lines) | stat: -rw-r--r-- 10,844 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/* $Header: /cvsroot/VTK/VTK/Utilities/vtktiff/tif_dir.h,v 1.1 2004/04/28 15:49:22 king Exp $ */

/*
 * Copyright (c) 1988-1997 Sam Leffler
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
 *
 * Permission to use, copy, modify, distribute, and sell this software and 
 * its documentation for any purpose is hereby granted without fee, provided
 * that (i) the above copyright notices and this permission notice appear in
 * all copies of the software and related documentation, and (ii) the names of
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
 * publicity relating to the software without the specific, prior written
 * permission of Sam Leffler and Silicon Graphics.
 * 
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
 * 
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
 * OF THIS SOFTWARE.
 */

#ifndef _TIFFDIR_
#define _TIFFDIR_
/*
 * ``Library-private'' Directory-related Definitions.
 */


/*
 * Internal format of a TIFF directory entry.
 */
typedef struct {
#define FIELD_SETLONGS  3
        /* bit vector of fields that are set */
        u_long  td_fieldsset[FIELD_SETLONGS];

        uint32  td_imagewidth, td_imagelength, td_imagedepth;
        uint32  td_tilewidth, td_tilelength, td_tiledepth;
        uint32  td_subfiletype;
        uint16  td_bitspersample;
        uint16  td_sampleformat;
        uint16  td_compression;
        uint16  td_photometric;
        uint16  td_threshholding;
        uint16  td_fillorder;
        uint16  td_orientation;
        uint16  td_samplesperpixel;
        uint32  td_rowsperstrip;
        uint16  td_minsamplevalue, td_maxsamplevalue;
        double  td_sminsamplevalue, td_smaxsamplevalue;
        float   td_xresolution, td_yresolution;
        uint16  td_resolutionunit;
        uint16  td_planarconfig;
        float   td_xposition, td_yposition;
        uint16  td_pagenumber[2];
        uint16* td_colormap[3];
        uint16  td_halftonehints[2];
        uint16  td_extrasamples;
        uint16* td_sampleinfo;
        double  td_stonits;
        char*   td_documentname;
        char*   td_artist;
        char*   td_datetime;
        char*   td_hostcomputer;
        char*   td_imagedescription;
        char*   td_make;
        char*   td_model;
        char*   td_software;
        char*   td_copyright;
        char*   td_pagename;
        tstrip_t td_stripsperimage;
        tstrip_t td_nstrips;            /* size of offset & bytecount arrays */
        uint32* td_stripoffset;
        uint32* td_stripbytecount;
#if SUBIFD_SUPPORT
        uint16  td_nsubifd;
        uint32* td_subifd;
#endif
#ifdef YCBCR_SUPPORT
        float*  td_ycbcrcoeffs;
        uint16  td_ycbcrsubsampling[2];
        uint16  td_ycbcrpositioning;
#endif
#ifdef COLORIMETRY_SUPPORT
        float*  td_whitepoint;
        float*  td_primarychromas;
        float*  td_refblackwhite;
        uint16* td_transferfunction[3];
#endif
#ifdef CMYK_SUPPORT
        uint16  td_inkset;
        uint16  td_ninks;
        uint16  td_dotrange[2];
        int     td_inknameslen;
        char*   td_inknames;
        char*   td_targetprinter;
#endif
#ifdef ICC_SUPPORT
        uint32  td_profileLength;
        void    *td_profileData;
#endif
#ifdef PHOTOSHOP_SUPPORT
        uint32  td_photoshopLength;
        void    *td_photoshopData;
#endif
#ifdef IPTC_SUPPORT
        uint32  td_richtiffiptcLength;
        void    *td_richtiffiptcData;
#endif
        /* Begin Pixar Tag values. */
        uint32  td_imagefullwidth, td_imagefulllength;
        char*   td_textureformat;
        char*   td_wrapmodes;
        float   td_fovcot;
        float*  td_matrixWorldToScreen;
        float*  td_matrixWorldToCamera;
        /* End Pixar Tag Values. */

        /* zeiss data */
        uint32  td_cz_lsminfoLength;
        void    *td_cz_lsminfoData;
  
        /* uic data */
        uint32  td_uic2tagLength;
        uint32 *td_uic2tagData;

} TIFFDirectory;

/*
 * Field flags used to indicate fields that have
 * been set in a directory, and to reference fields
 * when manipulating a directory.
 */

/*
 * FIELD_IGNORE is used to signify tags that are to
 * be processed but otherwise ignored.  This permits
 * antiquated tags to be quietly read and discarded.
 * Note that a bit *is* allocated for ignored tags;
 * this is understood by the directory reading logic
 * which uses this fact to avoid special-case handling
 */ 
#define FIELD_IGNORE                    0

/* multi-item fields */
#define FIELD_IMAGEDIMENSIONS           1
#define FIELD_TILEDIMENSIONS            2
#define FIELD_RESOLUTION                3
#define FIELD_POSITION                  4

/* single-item fields */
#define FIELD_SUBFILETYPE               5
#define FIELD_BITSPERSAMPLE             6
#define FIELD_COMPRESSION               7
#define FIELD_PHOTOMETRIC               8
#define FIELD_THRESHHOLDING             9
#define FIELD_FILLORDER                 10
#define FIELD_DOCUMENTNAME              11
#define FIELD_IMAGEDESCRIPTION          12
#define FIELD_MAKE                      13
#define FIELD_MODEL                     14
#define FIELD_ORIENTATION               15
#define FIELD_SAMPLESPERPIXEL           16
#define FIELD_ROWSPERSTRIP              17
#define FIELD_MINSAMPLEVALUE            18
#define FIELD_MAXSAMPLEVALUE            19
#define FIELD_PLANARCONFIG              20
#define FIELD_PAGENAME                  21
#define FIELD_RESOLUTIONUNIT            22
#define FIELD_PAGENUMBER                23
#define FIELD_STRIPBYTECOUNTS           24
#define FIELD_STRIPOFFSETS              25
#define FIELD_COLORMAP                  26
#define FIELD_ARTIST                    27
#define FIELD_DATETIME                  28
#define FIELD_HOSTCOMPUTER              29
#define FIELD_SOFTWARE                  30
#define FIELD_EXTRASAMPLES              31
#define FIELD_SAMPLEFORMAT              32
#define FIELD_SMINSAMPLEVALUE           33
#define FIELD_SMAXSAMPLEVALUE           34
#define FIELD_IMAGEDEPTH                35
#define FIELD_TILEDEPTH                 36
#define FIELD_HALFTONEHINTS             37
#define FIELD_YCBCRCOEFFICIENTS         38
#define FIELD_YCBCRSUBSAMPLING          39
#define FIELD_YCBCRPOSITIONING          40
#define FIELD_REFBLACKWHITE             41
#define FIELD_WHITEPOINT                42
#define FIELD_PRIMARYCHROMAS            43
#define FIELD_TRANSFERFUNCTION          44
#define FIELD_INKSET                    45
#define FIELD_INKNAMES                  46
#define FIELD_DOTRANGE                  47
#define FIELD_TARGETPRINTER             48
#define FIELD_SUBIFD                    49
#define FIELD_NUMBEROFINKS              50
#define FIELD_ICCPROFILE                51
#define FIELD_PHOTOSHOP                 52
#define FIELD_RICHTIFFIPTC              53
#define FIELD_STONITS                   54
/* Begin PIXAR */
#define FIELD_IMAGEFULLWIDTH            55
#define FIELD_IMAGEFULLLENGTH           56
#define FIELD_TEXTUREFORMAT             57
#define FIELD_WRAPMODES                 58
#define FIELD_FOVCOT                    59
#define FIELD_MATRIX_WORLDTOSCREEN      60
#define FIELD_MATRIX_WORLDTOCAMERA      61
#define FIELD_COPYRIGHT                 62
#define FIELD_CZ_LSMINFO                63
#define FIELD_UIC2TAG                   64
/* end of support for well-known tags; codec-private tags follow */
#define FIELD_CODEC                     65      /* base of codec-private tags */
/*
 * Pseudo-tags don't normally need field bits since they
 * are not written to an output file (by definition).
 * The library also has express logic to always query a
 * codec for a pseudo-tag so allocating a field bit for
 * one is a waste.   If codec wants to promote the notion
 * of a pseudo-tag being ``set'' or ``unset'' then it can
 * do using internal state flags without polluting the
 * field bit space defined for real tags.
 */
#define FIELD_PSEUDO                    0

#define FIELD_LAST                      (32*FIELD_SETLONGS-1)

#define TIFFExtractData(tif, type, v) \
    ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
        ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \
        (v) & (tif)->tif_typemask[type]))
#define TIFFInsertData(tif, type, v) \
    ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
        ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \
        (v) & (tif)->tif_typemask[type]))

typedef struct {
        ttag_t  field_tag;              /* field's tag */
        short   field_readcount;        /* read count/TIFF_VARIABLE/TIFF_SPP */
        short   field_writecount;       /* write count/TIFF_VARIABLE */
        TIFFDataType field_type;        /* type of associated data */
        u_short field_bit;              /* bit in fieldsset bit vector */
        u_char  field_oktochange;       /* if true, can change while writing */
        u_char  field_passcount;        /* if true, pass dir count on set */
        char    *field_name;            /* ASCII name */
} TIFFFieldInfo;

#define TIFF_ANY        TIFF_NOTYPE     /* for field descriptor searching */
#define TIFF_VARIABLE   -1              /* marker for variable length tags */
#define TIFF_SPP        -2              /* marker for SamplesPerPixel tags */
#define TIFF_VARIABLE2  -3              /* marker for uint32 var-length tags */

extern  const int tiffDataWidth[];      /* table of tag datatype widths */

#define BITn(n)                         (((u_long)1L)<<((n)&0x1f)) 
#define BITFIELDn(tif, n)               ((tif)->tif_dir.td_fieldsset[(n)/32]) 
#define TIFFFieldSet(tif, field)        (BITFIELDn(tif, field) & BITn(field)) 
#define TIFFSetFieldBit(tif, field)     (BITFIELDn(tif, field) |= BITn(field))
#define TIFFClrFieldBit(tif, field)     (BITFIELDn(tif, field) &= ~BITn(field))

#define FieldSet(fields, f)             (fields[(f)/32] & BITn(f))
#define ResetFieldBit(fields, f)        (fields[(f)/32] &= ~BITn(f))

#if defined(__cplusplus)
extern "C" {
#endif
extern  void _TIFFSetupFieldInfo(TIFF*);
extern  void _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int);
extern  void _TIFFPrintFieldInfo(TIFF*, FILE*);
extern  const TIFFFieldInfo* _TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType);
extern  const TIFFFieldInfo* _TIFFFieldWithTag(TIFF*, ttag_t);
extern  TIFFDataType _TIFFSampleToTagType(TIFF*);
#if defined(__cplusplus)
}
#endif
#endif /* _TIFFDIR_ */