00001 /*! 00002 ************************************************************************ 00003 * \file io_tiff.h 00004 * 00005 * \brief 00006 * I/O functions related to tiff images 00007 * Part of code was based on libtiff (see http://www.libtiff.org/) 00008 * 00009 * \author 00010 * - Alexis Michael Tourapis <alexismt@ieee.org> 00011 * 00012 ************************************************************************ 00013 */ 00014 00015 #ifndef _IO_TIFF_H_ 00016 #define _IO_TIFF_H_ 00017 // See TIFF 6.0 Specification 00018 // http://partners.adobe.com/public/developer/tiff/index.html 00019 00020 // TIFF header. 00021 typedef struct { 00022 unsigned char border[2]; //!< Byte order used (2 bytes). Valid values "II" (little endian) and "MM" (big endian). 00023 unsigned short version; //!< TIFF identification number, i.e. 42 (2 bytes) 00024 unsigned int IFDoff; //!< The offset (in bytes) of the first Image File Directory/IFD (4 bytes). 00025 } TIFFHeader; 00026 00027 00028 // TIFF IFD structure 00029 typedef struct { 00030 unsigned short tIFD_tag; //!< Identification tag 00031 unsigned short tIFD_type; //!< field type. 00032 unsigned int tIFD_count; //!< The number of values, Count of the indicated Type. 00033 unsigned int tIFD_offset; //!< The Value Offset, the file offset (in bytes) of the Value for the field. 00034 } TIFFIFDEntry; 00035 00036 // TIFF Types 00037 typedef enum { 00038 TIFF_BYTE = 1, // 8-bit unsigned integer. 00039 TIFF_ASCII = 2, // 8-bit byte that contains a 7-bit ASCII code. 00040 TIFF_SHORT = 3, // 16-bit (2-byte) unsigned integer. 00041 TIFF_LONG = 4, // 32-bit (4-byte) unsigned integer. 00042 TIFF_RATIONAL = 5, // Two LONGs: the first represents the numerator of 00043 // a fraction; the second, the denominator 00044 TIFF_SBYTE = 6, // An 8-bit signed (twos-complement) integer. 00045 TIFF_UNDEFINED = 7, // An 8-bit undefined byte. 00046 TIFF_SSHORT = 8, // A 16-bit (2-byte) signed (twos-complement) integer. 00047 TIFF_SLONG = 9, // A 32-bit (4-byte) signed (twos-complement) integer. 00048 TIFF_SRATIONAL = 10, // Two SLONG’s: the first represents the numerator of 00049 // a fraction, the second the denominator. 00050 TIFF_FLOAT = 11, // Single precision (4-byte) IEEE format 00051 TIFF_DOUBLE = 12, // Double precision (8-byte) IEEE format 00052 } TIFFType; 00053 // TIFF Types 00054 00055 typedef enum { 00056 TIFFTAG_SUBFILETYPE = 254, /* subfile data descriptor */ 00057 TIFFTAG_OSUBFILETYPE = 255, 00058 TIFFTAG_IMAGEWIDTH = 256, /* image width in pixels */ 00059 TIFFTAG_IMAGELENGTH = 257, /* image height in pixels */ 00060 TIFFTAG_BITSPERSAMPLE = 258, /* bits per channel (sample) */ 00061 TIFFTAG_COMPRESSION = 259, /* data compression technique */ 00062 TIFFTAG_PHOTOMETRIC = 262, /* photometric interpretation */ 00063 TIFFTAG_THRESHHOLDING = 263, /* +thresholding used on data */ 00064 TIFFTAG_CELLWIDTH = 264, /* +dithering matrix width */ 00065 TIFFTAG_CELLLENGTH = 265, /* +dithering matrix height */ 00066 TIFFTAG_FILLORDER = 266, /* data order within a byte */ 00067 TIFFTAG_DOCUMENTNAME = 269, /* name of doc. image is from */ 00068 TIFFTAG_IMAGEDESCRIPTION = 270, /* info about image */ 00069 TIFFTAG_MAKE = 271, /* scanner manufacturer name */ 00070 TIFFTAG_MODEL = 272, /* scanner model name/number */ 00071 TIFFTAG_STRIPOFFSETS = 273, /* offsets to data strips */ 00072 TIFFTAG_ORIENTATION = 274, /* +image orientation */ 00073 TIFFTAG_SAMPLESPERPIXEL = 277, /* samples per pixel */ 00074 TIFFTAG_ROWSPERSTRIP = 278, /* rows per strip of data */ 00075 TIFFTAG_STRIPBYTECOUNTS = 279, /* bytes counts for strips */ 00076 TIFFTAG_MINSAMPLEVALUE = 280, /* +minimum sample value */ 00077 TIFFTAG_MAXSAMPLEVALUE = 281, /* +maximum sample value */ 00078 TIFFTAG_XRESOLUTION = 282, /* pixels/resolution in x */ 00079 TIFFTAG_YRESOLUTION = 283, /* pixels/resolution in y */ 00080 TIFFTAG_PLANARCONFIG = 284, /* storage organization */ 00081 TIFFTAG_PAGENAME = 285, /* page name image is from */ 00082 TIFFTAG_XPOSITION = 286, /* x page offset of image lhs */ 00083 TIFFTAG_YPOSITION = 287, /* y page offset of image lhs */ 00084 TIFFTAG_FREEOFFSETS = 288, /* +byte offset to free block */ 00085 TIFFTAG_FREEBYTECOUNTS = 289, /* +sizes of free blocks */ 00086 TIFFTAG_GRAYRESPONSEUNIT = 290, /* $gray scale curve accuracy */ 00087 TIFFTAG_GRAYRESPONSECURVE = 291, /* $gray scale response curve */ 00088 TIFFTAG_GROUP3OPTIONS = 292, /* 32 flag bits */ 00089 TIFFTAG_T4OPTIONS = 292, /* TIFF 6.0 proper name alias */ 00090 TIFFTAG_GROUP4OPTIONS = 293, /* 32 flag bits */ 00091 TIFFTAG_T6OPTIONS = 293 , /* TIFF 6.0 proper name */ 00092 TIFFTAG_RESOLUTIONUNIT = 296, /* units of resolutions */ 00093 TIFFTAG_PAGENUMBER = 297, /* page numbers of multi-page */ 00094 TIFFTAG_COLORRESPONSEUNIT = 300, /* $color curve accuracy */ 00095 TIFFTAG_TRANSFERFUNCTION = 301, /* !colorimetry info */ 00096 TIFFTAG_SOFTWARE = 305, /* name & release */ 00097 TIFFTAG_DATETIME = 306, /* creation date and time */ 00098 TIFFTAG_ARTIST = 315, /* creator of image */ 00099 TIFFTAG_HOSTCOMPUTER = 316, /* machine where created */ 00100 TIFFTAG_PREDICTOR = 317, /* prediction scheme w/ LZW */ 00101 TIFFTAG_WHITEPOINT = 318, /* image white point */ 00102 TIFFTAG_PRIMARYCHROMATICITIES = 319, /* !primary chromaticities */ 00103 TIFFTAG_COLORMAP = 320, /* RGB map for pallette image */ 00104 TIFFTAG_HALFTONEHINTS = 321, /* !highlight+shadow info */ 00105 TIFFTAG_TILEWIDTH = 322, /* !tile width in pixels */ 00106 TIFFTAG_TILELENGTH = 323, /* !tile height in pixels */ 00107 TIFFTAG_TILEOFFSETS = 324, /* !offsets to data tiles */ 00108 TIFFTAG_TILEBYTECOUNTS = 325, /* !byte counts for tiles */ 00109 TIFFTAG_BADFAXLINES = 326, /* lines w/ wrong pixel count */ 00110 TIFFTAG_CLEANFAXDATA = 327, /* regenerated line info */ 00111 TIFFTAG_CONSECUTIVEBADFAXLINES = 328, /* max consecutive bad lines */ 00112 TIFFTAG_SUBIFD = 330, /* subimage descriptors */ 00113 TIFFTAG_INKSET = 332, /* !inks in separated image */ 00114 TIFFTAG_INKNAMES = 333, /* !ascii names of inks */ 00115 TIFFTAG_NUMBEROFINKS = 334, /* !number of inks */ 00116 TIFFTAG_DOTRANGE = 336, /* !0% and 100% dot codes */ 00117 TIFFTAG_TARGETPRINTER = 337, /* !separation target */ 00118 TIFFTAG_EXTRASAMPLES = 338, /* !info about extra samples */ 00119 TIFFTAG_SAMPLEFORMAT = 339, /* !data sample format */ 00120 TIFFTAG_SMINSAMPLEVALUE = 340, /* !variable MinSampleValue */ 00121 TIFFTAG_SMAXSAMPLEVALUE = 341, /* !variable MaxSampleValue */ 00122 } TIFFTag; 00123 00124 typedef enum { 00125 COMPRESSION_NONE = 1, /* dump mode (only mode that will be initially supported) */ 00126 COMPRESSION_CCITTRLE = 2, /* CCITT modified Huffman RLE */ 00127 COMPRESSION_CCITTFAX3 = 3, /* CCITT Group 3 fax encoding */ 00128 COMPRESSION_CCITT_T4 = 3, /* CCITT T.4 (TIFF 6 name) */ 00129 COMPRESSION_CCITTFAX4 = 4, /* CCITT Group 4 fax encoding */ 00130 COMPRESSION_CCITT_T6 = 4, /* CCITT T.6 (TIFF 6 name) */ 00131 COMPRESSION_LZW = 5, /* Lempel-Ziv & Welch */ 00132 COMPRESSION_OJPEG = 6, /* !6.0 JPEG */ 00133 COMPRESSION_JPEG = 7, /* %JPEG DCT compression */ 00134 } TIFFCompression; 00135 00136 00137 void ReadTIFFImage (VideoDataFile *input_file, int FrameNoInFile, FrameFormat *source, unsigned char *buf); 00138 00139 #endif 00140