home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / graphics / libtiff_1 / h / tiff < prev    next >
Text File  |  1995-10-12  |  17KB  |  334 lines

  1. /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiff.h,v 1.60 1995/10/12 16:25:42 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 _TIFF_
  28. #define    _TIFF_
  29. /*
  30.  * Tag Image File Format (TIFF)
  31.  *
  32.  * Based on Rev 6.0 from:
  33.  *    Developer's Desk
  34.  *    Aldus Corporation
  35.  *    411 First Ave. South
  36.  *    Suite 200
  37.  *    Seattle, WA  98104
  38.  *    206-622-5500
  39.  */
  40. #define    TIFF_VERSION    42
  41.  
  42. #define    TIFF_BIGENDIAN        0x4d4d
  43. #define    TIFF_LITTLEENDIAN    0x4949
  44.  
  45. /*
  46.  * Intrinsic data types required by the file format:
  47.  *
  48.  * 8-bit quantities    int8/uint8
  49.  * 16-bit quantities    int16/uint16
  50.  * 32-bit quantities    int32/uint32
  51.  * strings        unsigned char*
  52.  */
  53. typedef    signed char int8;    /* NB: non-ANSI compilers may not grok */
  54. typedef    unsigned char uint8;
  55. typedef    short int16;
  56. typedef    unsigned short uint16;    /* sizeof (uint16) must == 2 */
  57. #if defined(__alpha) || (defined(_MIPS_SZLONG) && _MIPS_SZLONG == 64)
  58. typedef    int int32;
  59. typedef    unsigned int uint32;    /* sizeof (uint32) must == 4 */
  60. #else
  61. typedef    long int32;
  62. typedef    unsigned long uint32;    /* sizeof (uint32) must == 4 */
  63. #endif
  64.  
  65. typedef    struct {
  66.     uint16    tiff_magic;    /* magic number (defines byte order) */
  67.     uint16    tiff_version;    /* TIFF version number */
  68.     uint32    tiff_diroff;    /* byte offset to first directory */
  69. } TIFFHeader;
  70.  
  71. /*
  72.  * TIFF Image File Directories are comprised of
  73.  * a table of field descriptors of the form shown
  74.  * below.  The table is sorted in ascending order
  75.  * by tag.  The values associated with each entry
  76.  * are disjoint and may appear anywhere in the file
  77.  * (so long as they are placed on a word boundary).
  78.  *
  79.  * If the value is 4 bytes or less, then it is placed
  80.  * in the offset field to save space.  If the value
  81.  * is less than 4 bytes, it is left-justified in the
  82.  * offset field.
  83.  */
  84. typedef    struct {
  85.     uint16    tdir_tag;    /* see below */
  86.     uint16    tdir_type;    /* data type; see below */
  87.     uint32  tdir_count;    /* number of items; length in spec */
  88.     uint32  tdir_offset;    /* byte offset to field data */
  89. } TIFFDirEntry;
  90.  
  91. /*
  92.  * NB: In the comments below,
  93.  *  - items marked with a + are obsoleted by revision 5.0,
  94.  *  - items marked with a ! are introduced in revision 6.0.
  95.  *  - items marked with a % are introduced post revision 6.0.
  96.  *  - items marked with a $ are obsoleted by revision 6.0.
  97.  */
  98.  
  99. /*
  100.  * Tag data type information.
  101.  *
  102.  * Note: RATIONALs are the ratio of two 32-bit integer values.
  103.  */
  104. typedef    enum {
  105.     TIFF_NOTYPE    = 0,    /* placeholder */
  106.     TIFF_BYTE    = 1,    /* 8-bit unsigned integer */
  107.     TIFF_ASCII    = 2,    /* 8-bit bytes w/ last byte null */
  108.     TIFF_SHORT    = 3,    /* 16-bit unsigned integer */
  109.     TIFF_LONG    = 4,    /* 32-bit unsigned integer */
  110.     TIFF_RATIONAL    = 5,    /* 64-bit unsigned fraction */
  111.     TIFF_SBYTE    = 6,    /* !8-bit signed integer */
  112.     TIFF_UNDEFINED    = 7,    /* !8-bit untyped data */
  113.     TIFF_SSHORT    = 8,    /* !16-bit signed integer */
  114.     TIFF_SLONG    = 9,    /* !32-bit signed integer */
  115.     TIFF_SRATIONAL    = 10,    /* !64-bit signed fraction */
  116.     TIFF_FLOAT    = 11,    /* !32-bit IEEE floating point */
  117.     TIFF_DOUBLE    = 12    /* !64-bit IEEE floating point */
  118. } TIFFDataType;
  119.  
  120. /*
  121.  * TIFF Tag Definitions.
  122.  */
  123. #define    TIFFTAG_SUBFILETYPE        254    /* subfile data descriptor */
  124. #define        FILETYPE_REDUCEDIMAGE    0x1    /* reduced resolution version */
  125. #define        FILETYPE_PAGE        0x2    /* one page of many */
  126. #define        FILETYPE_MASK        0x4    /* transparency mask */
  127. #define    TIFFTAG_OSUBFILETYPE        255    /* +kind of data in subfile */
  128. #define        OFILETYPE_IMAGE        1    /* full resolution image data */
  129. #define        OFILETYPE_REDUCEDIMAGE    2    /* reduced size image data */
  130. #define        OFILETYPE_PAGE        3    /* one page of many */
  131. #define    TIFFTAG_IMAGEWIDTH        256    /* image width in pixels */
  132. #define    TIFFTAG_IMAGELENGTH        257    /* image height in pixels */
  133. #define    TIFFTAG_BITSPERSAMPLE        258    /* bits per channel (sample) */
  134. #define    TIFFTAG_COMPRESSION        259    /* data compression technique */
  135. #define        COMPRESSION_NONE        1    /* dump mode */
  136. #define        COMPRESSION_CCITTRLE    2    /* CCITT modified Huffman RLE */
  137. #define        COMPRESSION_CCITTFAX3    3    /* CCITT Group 3 fax encoding */
  138. #define        COMPRESSION_CCITTFAX4    4    /* CCITT Group 4 fax encoding */
  139. #define        COMPRESSION_LZW        5    /* Lempel-Ziv  & Welch */
  140. #define        COMPRESSION_OJPEG        6    /* !6.0 JPEG */
  141. #define        COMPRESSION_JPEG        7    /* %JPEG DCT compression */
  142. #define        COMPRESSION_NEXT        32766    /* NeXT 2-bit RLE */
  143. #define        COMPRESSION_CCITTRLEW    32771    /* #1 w/ word alignment */
  144. #define        COMPRESSION_PACKBITS    32773    /* Macintosh RLE */
  145. #define        COMPRESSION_THUNDERSCAN    32809    /* ThunderScan RLE */
  146. /* compression codes 32908-32911 are reserved for Pixar */
  147. #define     COMPRESSION_PIXARFILM       32908   /* Pixar companded 10bit LZW */
  148. #define        COMPRESSION_DEFLATE        32946    /* Deflate compression */
  149. #define        COMPRESSION_JBIG        34661    /* ISO JBIG */
  150. #define    TIFFTAG_PHOTOMETRIC        262    /* photometric interpretation */
  151. #define        PHOTOMETRIC_MINISWHITE    0    /* min value is white */
  152. #define        PHOTOMETRIC_MINISBLACK    1    /* min value is black */
  153. #define        PHOTOMETRIC_RGB        2    /* RGB color model */
  154. #define        PHOTOMETRIC_PALETTE        3    /* color map indexed */
  155. #define        PHOTOMETRIC_MASK        4    /* $holdout mask */
  156. #define        PHOTOMETRIC_SEPARATED    5    /* !color separations */
  157. #define        PHOTOMETRIC_YCBCR        6    /* !CCIR 601 */
  158. #define        PHOTOMETRIC_CIELAB        8    /* !1976 CIE L*a*b* */
  159. #define    TIFFTAG_THRESHHOLDING        263    /* +thresholding used on data */
  160. #define        THRESHHOLD_BILEVEL        1    /* b&w art scan */
  161. #define        THRESHHOLD_HALFTONE        2    /* or dithered scan */
  162. #define        THRESHHOLD_ERRORDIFFUSE    3    /* usually floyd-steinberg */
  163. #define    TIFFTAG_CELLWIDTH        264    /* +dithering matrix width */
  164. #define    TIFFTAG_CELLLENGTH        265    /* +dithering matrix height */
  165. #define    TIFFTAG_FILLORDER        266    /* data order within a byte */
  166. #define        FILLORDER_MSB2LSB        1    /* most significant -> least */
  167. #define        FILLORDER_LSB2MSB        2    /* least significant -> most */
  168. #define    TIFFTAG_DOCUMENTNAME        269    /* name of doc. image is from */
  169. #define    TIFFTAG_IMAGEDESCRIPTION    270    /* info about image */
  170. #define    TIFFTAG_MAKE            271    /* scanner manufacturer name */
  171. #define    TIFFTAG_MODEL            272    /* scanner model name/number */
  172. #define    TIFFTAG_STRIPOFFSETS        273    /* offsets to data strips */
  173. #define    TIFFTAG_ORIENTATION        274    /* +image orientation */
  174. #define        ORIENTATION_TOPLEFT        1    /* row 0 top, col 0 lhs */
  175. #define        ORIENTATION_TOPRIGHT    2    /* row 0 top, col 0 rhs */
  176. #define        ORIENTATION_BOTRIGHT    3    /* row 0 bottom, col 0 rhs */
  177. #define        ORIENTATION_BOTLEFT        4    /* row 0 bottom, col 0 lhs */
  178. #define        ORIENTATION_LEFTTOP        5    /* row 0 lhs, col 0 top */
  179. #define        ORIENTATION_RIGHTTOP    6    /* row 0 rhs, col 0 top */
  180. #define        ORIENTATION_RIGHTBOT    7    /* row 0 rhs, col 0 bottom */
  181. #define        ORIENTATION_LEFTBOT        8    /* row 0 lhs, col 0 bottom */
  182. #define    TIFFTAG_SAMPLESPERPIXEL        277    /* samples per pixel */
  183. #define    TIFFTAG_ROWSPERSTRIP        278    /* rows per strip of data */
  184. #define    TIFFTAG_STRIPBYTECOUNTS        279    /* bytes counts for strips */
  185. #define    TIFFTAG_MINSAMPLEVALUE        280    /* +minimum sample value */
  186. #define    TIFFTAG_MAXSAMPLEVALUE        281    /* +maximum sample value */
  187. #define    TIFFTAG_XRESOLUTION        282    /* pixels/resolution in x */
  188. #define    TIFFTAG_YRESOLUTION        283    /* pixels/resolution in y */
  189. #define    TIFFTAG_PLANARCONFIG        284    /* storage organization */
  190. #define        PLANARCONFIG_CONTIG        1    /* single image plane */
  191. #define        PLANARCONFIG_SEPARATE    2    /* separate planes of data */
  192. #define    TIFFTAG_PAGENAME        285    /* page name image is from */
  193. #define    TIFFTAG_XPOSITION        286    /* x page offset of image lhs */
  194. #define    TIFFTAG_YPOSITION        287    /* y page offset of image lhs */
  195. #define    TIFFTAG_FREEOFFSETS        288    /* +byte offset to free block */
  196. #define    TIFFTAG_FREEBYTECOUNTS        289    /* +sizes of free blocks */
  197. #define    TIFFTAG_GRAYRESPONSEUNIT    290    /* $gray scale curve accuracy */
  198. #define        GRAYRESPONSEUNIT_10S    1    /* tenths of a unit */
  199. #define        GRAYRESPONSEUNIT_100S    2    /* hundredths of a unit */
  200. #define        GRAYRESPONSEUNIT_1000S    3    /* thousandths of a unit */
  201. #define        GRAYRESPONSEUNIT_10000S    4    /* ten-thousandths of a unit */
  202. #define        GRAYRESPONSEUNIT_100000S    5    /* hundred-thousandths */
  203. #define    TIFFTAG_GRAYRESPONSECURVE    291    /* $gray scale response curve */
  204. #define    TIFFTAG_GROUP3OPTIONS        292    /* 32 flag bits */
  205. #define        GROUP3OPT_2DENCODING    0x1    /* 2-dimensional coding */
  206. #define        GROUP3OPT_UNCOMPRESSED    0x2    /* data not compressed */
  207. #define        GROUP3OPT_FILLBITS        0x4    /* fill to byte boundary */
  208. #define    TIFFTAG_GROUP4OPTIONS        293    /* 32 flag bits */
  209. #define        GROUP4OPT_UNCOMPRESSED    0x2    /* data not compressed */
  210. #define    TIFFTAG_RESOLUTIONUNIT        296    /* units of resolutions */
  211. #define        RESUNIT_NONE        1    /* no meaningful units */
  212. #define        RESUNIT_INCH        2    /* english */
  213. #define        RESUNIT_CENTIMETER        3    /* metric */
  214. #define    TIFFTAG_PAGENUMBER        297    /* page numbers of multi-page */
  215. #define    TIFFTAG_COLORRESPONSEUNIT    300    /* $color curve accuracy */
  216. #define        COLORRESPONSEUNIT_10S    1    /* tenths of a unit */
  217. #define        COLORRESPONSEUNIT_100S    2    /* hundredths of a unit */
  218. #define        COLORRESPONSEUNIT_1000S    3    /* thousandths of a unit */
  219. #define        COLORRESPONSEUNIT_10000S    4    /* ten-thousandths of a unit */
  220. #define        COLORRESPONSEUNIT_100000S    5    /* hundred-thousandths */
  221. #define    TIFFTAG_TRANSFERFUNCTION    301    /* !colorimetry info */
  222. #define    TIFFTAG_SOFTWARE        305    /* name & release */
  223. #define    TIFFTAG_DATETIME        306    /* creation date and time */
  224. #define    TIFFTAG_ARTIST            315    /* creator of image */
  225. #define    TIFFTAG_HOSTCOMPUTER        316    /* machine where created */
  226. #define    TIFFTAG_PREDICTOR        317    /* prediction scheme w/ LZW */
  227. #define    TIFFTAG_WHITEPOINT        318    /* image white point */
  228. #define    TIFFTAG_PRIMARYCHROMATICITIES    319    /* !primary chromaticities */
  229. #define    TIFFTAG_COLORMAP        320    /* RGB map for pallette image */
  230. #define    TIFFTAG_HALFTONEHINTS        321    /* !highlight+shadow info */
  231. #define    TIFFTAG_TILEWIDTH        322    /* !rows/data tile */
  232. #define    TIFFTAG_TILELENGTH        323    /* !cols/data tile */
  233. #define TIFFTAG_TILEOFFSETS        324    /* !offsets to data tiles */
  234. #define TIFFTAG_TILEBYTECOUNTS        325    /* !byte counts for tiles */
  235. #define    TIFFTAG_BADFAXLINES        326    /* lines w/ wrong pixel count */
  236. #define    TIFFTAG_CLEANFAXDATA        327    /* regenerated line info */
  237. #define        CLEANFAXDATA_CLEAN        0    /* no errors detected */
  238. #define        CLEANFAXDATA_REGENERATED    1    /* receiver regenerated lines */
  239. #define        CLEANFAXDATA_UNCLEAN    2    /* uncorrected errors exist */
  240. #define    TIFFTAG_CONSECUTIVEBADFAXLINES    328    /* max consecutive bad lines */
  241. #define    TIFFTAG_SUBIFD            330    /* subimage descriptors */
  242. #define    TIFFTAG_INKSET            332    /* !inks in separated image */
  243. #define        INKSET_CMYK            1    /* !cyan-magenta-yellow-black */
  244. #define    TIFFTAG_INKNAMES        333    /* !ascii names of inks */
  245. #define    TIFFTAG_DOTRANGE        336    /* !0% and 100% dot codes */
  246. #define    TIFFTAG_TARGETPRINTER        337    /* !separation target */
  247. #define    TIFFTAG_EXTRASAMPLES        338    /* !info about extra samples */
  248. #define        EXTRASAMPLE_UNSPECIFIED    0    /* !unspecified data */
  249. #define        EXTRASAMPLE_ASSOCALPHA    1    /* !associated alpha data */
  250. #define        EXTRASAMPLE_UNASSALPHA    2    /* !unassociated alpha data */
  251. #define    TIFFTAG_SAMPLEFORMAT        339    /* !data sample format */
  252. #define        SAMPLEFORMAT_UINT        1    /* !unsigned integer data */
  253. #define        SAMPLEFORMAT_INT        2    /* !signed integer data */
  254. #define        SAMPLEFORMAT_IEEEFP        3    /* !IEEE floating point data */
  255. #define        SAMPLEFORMAT_VOID        4    /* !untyped data */
  256. #define    TIFFTAG_SMINSAMPLEVALUE        340    /* !variable MinSampleValue */
  257. #define    TIFFTAG_SMAXSAMPLEVALUE        341    /* !variable MaxSampleValue */
  258. #define    TIFFTAG_JPEGTABLES        347    /* %JPEG table stream */
  259. /*
  260.  * Tags 512-521 are obsoleted by Technical Note #2
  261.  * which specifies a revised JPEG-in-TIFF scheme.
  262.  */
  263. #define    TIFFTAG_JPEGPROC        512    /* !JPEG processing algorithm */
  264. #define        JPEGPROC_BASELINE        1    /* !baseline sequential */
  265. #define        JPEGPROC_LOSSLESS        14    /* !Huffman coded lossless */
  266. #define    TIFFTAG_JPEGIFOFFSET        513    /* !pointer to SOI marker */
  267. #define    TIFFTAG_JPEGIFBYTECOUNT        514    /* !JFIF stream length */
  268. #define    TIFFTAG_JPEGRESTARTINTERVAL    515    /* !restart interval length */
  269. #define    TIFFTAG_JPEGLOSSLESSPREDICTORS    517    /* !lossless proc predictor */
  270. #define    TIFFTAG_JPEGPOINTTRANSFORM    518    /* !lossless point transform */
  271. #define    TIFFTAG_JPEGQTABLES        519    /* !Q matrice offsets */
  272. #define    TIFFTAG_JPEGDCTABLES        520    /* !DCT table offsets */
  273. #define    TIFFTAG_JPEGACTABLES        521    /* !AC coefficient offsets */
  274. #define    TIFFTAG_YCBCRCOEFFICIENTS    529    /* !RGB -> YCbCr transform */
  275. #define    TIFFTAG_YCBCRSUBSAMPLING    530    /* !YCbCr subsampling factors */
  276. #define    TIFFTAG_YCBCRPOSITIONING    531    /* !subsample positioning */
  277. #define        YCBCRPOSITION_CENTERED    1    /* !as in PostScript Level 2 */
  278. #define        YCBCRPOSITION_COSITED    2    /* !as in CCIR 601-1 */
  279. #define    TIFFTAG_REFERENCEBLACKWHITE    532    /* !colorimetry info */
  280. /* tags 32952-32956 are private tags registered to Island Graphics */
  281. #define TIFFTAG_REFPTS            32953    /* image reference points */
  282. #define TIFFTAG_REGIONTACKPOINT        32954    /* region-xform tack point */
  283. #define TIFFTAG_REGIONWARPCORNERS    32955    /* warp quadrilateral */
  284. #define TIFFTAG_REGIONAFFINE        32956    /* affine transformation mat */
  285. /* tags 32995-32999 are private tags registered to SGI */
  286. #define    TIFFTAG_MATTEING        32995    /* $use ExtraSamples */
  287. #define    TIFFTAG_DATATYPE        32996    /* $use SampleFormat */
  288. #define    TIFFTAG_IMAGEDEPTH        32997    /* z depth of image */
  289. #define    TIFFTAG_TILEDEPTH        32998    /* z depth/data tile */
  290. /* tags 33300-33309 are private tags registered to Pixar */
  291. /*
  292.  * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH
  293.  * are set when an image has been cropped out of a larger image.  
  294.  * They reflect the size of the original uncropped image.
  295.  * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used
  296.  * to determine the position of the smaller image in the larger one.
  297.  */
  298. #define TIFFTAG_PIXAR_IMAGEFULLWIDTH    33300   /* full image size in x */
  299. #define TIFFTAG_PIXAR_IMAGEFULLLENGTH   33301   /* full image size in y */
  300. /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */
  301. #define    TIFFTAG_COPYRIGHT        33432    /* copyright string */
  302. /* tag 34750 is a private tag registered to Pixel Magic */
  303. #define    TIFFTAG_JBIGOPTIONS        34750    /* JBIG options */
  304.  
  305. /*
  306.  * The following are ``pseudo tags'' that can be
  307.  * used to control codec-specific functionality.
  308.  * These tags are not written to file.  Note that
  309.  * these values start at 0xffff+1 so that they'll
  310.  * never collide with Aldus-assigned tags.
  311.  *
  312.  * If you want your private pseudo tags ``registered''
  313.  * (i.e. added to this file), send mail to sam@sgi.com
  314.  * with the appropriate C definitions to add.
  315.  */
  316. #define    TIFFTAG_FAXMODE            65536    /* Group 3/4 format control */
  317. #define        FAXMODE_CLASSIC    0x0000        /* default, include RTC */
  318. #define        FAXMODE_NORTC    0x0001        /* no RTC at end of data */
  319. #define        FAXMODE_NOEOL    0x0002        /* no EOL code at end of row */
  320. #define        FAXMODE_BYTEALIGN    0x0004        /* byte align row */
  321. #define        FAXMODE_WORDALIGN    0x0008        /* word align row */
  322. #define        FAXMODE_CLASSF    FAXMODE_NORTC    /* TIFF Class F */
  323. #define    TIFFTAG_JPEGQUALITY        65537    /* Compression quality level */
  324. /* Note: quality level is on the IJG 0-100 scale.  Default value is 75 */
  325. #define    TIFFTAG_JPEGCOLORMODE        65538    /* Auto RGB<=>YCbCr convert? */
  326. #define        JPEGCOLORMODE_RAW    0x0000        /* no conversion (default) */
  327. #define        JPEGCOLORMODE_RGB    0x0001        /* do auto conversion */
  328. #define    TIFFTAG_JPEGTABLESMODE        65539    /* What to put in JPEGTables */
  329. #define        JPEGTABLESMODE_QUANT 0x0001        /* include quantization tbls */
  330. #define        JPEGTABLESMODE_HUFF    0x0002        /* include Huffman tbls */
  331. /* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */
  332. #define    TIFFTAG_FAXFILLFUNC        65540    /* G3/G4 fill function */
  333. #endif /* _TIFF_ */
  334.