home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsf / libtiff / h / tif_dir < prev    next >
Encoding:
Text File  |  1995-10-12  |  7.1 KB  |  221 lines

  1. /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dir.h,v 1.2 1995/06/30 05:46:47 sam Exp $ */
  2.  
  3. /*
  4.  * Copyright (c) 1988-1995 Sam Leffler
  5.  * Copyright (c) 1991-1995 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.     char*    td_documentname;
  65.     char*    td_artist;
  66.     char*    td_datetime;
  67.     char*    td_hostcomputer;
  68.     char*    td_imagedescription;
  69.     char*    td_make;
  70.     char*    td_model;
  71.     char*    td_software;
  72.     char*    td_pagename;
  73.     tstrip_t td_stripsperimage;
  74.     tstrip_t td_nstrips;        /* size of offset & bytecount arrays */
  75.     uint32*    td_stripoffset;
  76.     uint32*    td_stripbytecount;
  77. #if SUBIFD_SUPPORT
  78.     uint16    td_nsubifd;
  79.     uint32*    td_subifd;
  80. #endif
  81. #ifdef YCBCR_SUPPORT
  82.     float*    td_ycbcrcoeffs;
  83.     uint16    td_ycbcrsubsampling[2];
  84.     uint16    td_ycbcrpositioning;
  85. #endif
  86. #ifdef COLORIMETRY_SUPPORT
  87.     float*    td_whitepoint;
  88.     float*    td_primarychromas;
  89.     float*    td_refblackwhite;
  90.     uint16*    td_transferfunction[3];
  91. #endif
  92. #ifdef CMYK_SUPPORT
  93.     uint16    td_inkset;
  94.     uint16    td_dotrange[2];
  95.     char*    td_inknames;
  96.     char*    td_targetprinter;
  97. #endif
  98. } TIFFDirectory;
  99.  
  100. /*
  101.  * Field flags used to indicate fields that have
  102.  * been set in a directory, and to reference fields
  103.  * when manipulating a directory.
  104.  */
  105.  
  106. /*
  107.  * FIELD_IGNORE is used to signify tags that are to
  108.  * be processed but otherwise ignored.  This permits
  109.  * antiquated tags to be quietly read and discarded.
  110.  * Note that a bit *is* allocated for ignored tags;
  111.  * this is understood by the directory reading logic
  112.  * which uses this fact to avoid special-case handling
  113.  */ 
  114. #define    FIELD_IGNORE            0
  115.  
  116. /* multi-item fields */
  117. #define    FIELD_IMAGEDIMENSIONS        1
  118. #define FIELD_TILEDIMENSIONS        2
  119. #define    FIELD_RESOLUTION        3
  120. #define    FIELD_POSITION            4
  121.  
  122. /* single-item fields */
  123. #define    FIELD_SUBFILETYPE        5
  124. #define    FIELD_BITSPERSAMPLE        6
  125. #define    FIELD_COMPRESSION        7
  126. #define    FIELD_PHOTOMETRIC        8
  127. #define    FIELD_THRESHHOLDING        9
  128. #define    FIELD_FILLORDER            10
  129. #define    FIELD_DOCUMENTNAME        11
  130. #define    FIELD_IMAGEDESCRIPTION        12
  131. #define    FIELD_MAKE            13
  132. #define    FIELD_MODEL            14
  133. #define    FIELD_ORIENTATION        15
  134. #define    FIELD_SAMPLESPERPIXEL        16
  135. #define    FIELD_ROWSPERSTRIP        17
  136. #define    FIELD_MINSAMPLEVALUE        18
  137. #define    FIELD_MAXSAMPLEVALUE        19
  138. #define    FIELD_PLANARCONFIG        20
  139. #define    FIELD_PAGENAME            21
  140. #define    FIELD_RESOLUTIONUNIT        22
  141. #define    FIELD_PAGENUMBER        23
  142. #define    FIELD_STRIPBYTECOUNTS        24
  143. #define    FIELD_STRIPOFFSETS        25
  144. #define    FIELD_COLORMAP            26
  145. #define FIELD_ARTIST            27
  146. #define FIELD_DATETIME            28
  147. #define FIELD_HOSTCOMPUTER        29
  148. #define FIELD_SOFTWARE            30
  149. #define    FIELD_EXTRASAMPLES        31
  150. #define FIELD_SAMPLEFORMAT        32
  151. #define    FIELD_SMINSAMPLEVALUE        33
  152. #define    FIELD_SMAXSAMPLEVALUE        34
  153. #define FIELD_IMAGEDEPTH        35
  154. #define FIELD_TILEDEPTH            36
  155. #define    FIELD_HALFTONEHINTS        37
  156. #define FIELD_YCBCRCOEFFICIENTS        38
  157. #define FIELD_YCBCRSUBSAMPLING        39
  158. #define FIELD_YCBCRPOSITIONING        40
  159. #define    FIELD_REFBLACKWHITE        41
  160. #define    FIELD_WHITEPOINT        42
  161. #define    FIELD_PRIMARYCHROMAS        43
  162. #define    FIELD_TRANSFERFUNCTION        44
  163. #define    FIELD_INKSET            45
  164. #define    FIELD_INKNAMES            46
  165. #define    FIELD_DOTRANGE            47
  166. #define    FIELD_TARGETPRINTER        48
  167. #define    FIELD_SUBIFD            49
  168.  
  169. #define    FIELD_CODEC            50    /* base of codec-private tags */
  170.  
  171. #define    FIELD_LAST            (32*FIELD_SETLONGS-1)
  172.  
  173. #define    TIFFExtractData(tif, type, v) \
  174.     ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
  175.         ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \
  176.     (v) & (tif)->tif_typemask[type]))
  177. #define    TIFFInsertData(tif, type, v) \
  178.     ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
  179.         ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \
  180.     (v) & (tif)->tif_typemask[type]))
  181.  
  182. typedef    struct {
  183.     ttag_t    field_tag;        /* field's tag */
  184.     short    field_readcount;    /* read count (-1 for unknown) */
  185.     short    field_writecount;    /* write count (-1 for unknown) */
  186.     TIFFDataType field_type;    /* type of associated data */
  187.     u_short    field_bit;        /* bit in fieldsset bit vector */
  188.     u_char    field_oktochange;    /* if true, can change while writing */
  189.     u_char    field_passcount;    /* if true, pass dir count on set */
  190.     char    *field_name;        /* ASCII name */
  191. } TIFFFieldInfo;
  192.  
  193. #define    TIFF_ANY    TIFF_NOTYPE    /* for field descriptor searching */
  194. #define    TIFF_VARIABLE    -1        /* marker for variable length tags */
  195. #define    TIFF_SPP    -2        /* marker for SamplesPerPixel tags */
  196.  
  197. extern    const int tiffDataWidth[];    /* table of tag datatype widths */
  198.  
  199. #define BITn(n)                (((u_long)1L)<<((n)&0x1f)) 
  200. #define BITFIELDn(tif, n)        ((tif)->tif_dir.td_fieldsset[(n)/32]) 
  201. #define TIFFFieldSet(tif, field)    (BITFIELDn(tif, field) & BITn(field)) 
  202. #define TIFFSetFieldBit(tif, field)    (BITFIELDn(tif, field) |= BITn(field))
  203. #define TIFFClrFieldBit(tif, field)    (BITFIELDn(tif, field) &= ~BITn(field))
  204.  
  205. #define    FieldSet(fields, f)        (fields[(f)/32] & BITn(f))
  206. #define    ResetFieldBit(fields, f)    (fields[(f)/32] &= ~BITn(f))
  207.  
  208. #if defined(__cplusplus)
  209. extern "C" {
  210. #endif
  211. extern    void _TIFFSetupFieldInfo(TIFF*);
  212. extern    void _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int);
  213. extern    void _TIFFPrintFieldInfo(TIFF*, FILE*);
  214. extern    const TIFFFieldInfo* _TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType);
  215. extern    const TIFFFieldInfo* _TIFFFieldWithTag(TIFF*, ttag_t);
  216. extern    TIFFDataType _TIFFSampleToTagType(TIFF*);
  217. #if defined(__cplusplus)
  218. }
  219. #endif
  220. #endif /* _TIFFDIR_ */
  221.