Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

335 lines
19 KiB

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