Bobby Bodenheimer CS 258 Introduction to Graphics Fall 2003 The Tiff Image Specification
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 Big-Endian and Little-Endian Big-Endian: most significant byte to least significant byte both for 16-bit and 32-bit integers. This is the “normal” way we write numbers out. Little-Endian: least significant byte to most significant, again for both 16- and 32-bit integers.
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 Some Sample Code void SwapShortBytes(unsigned short int * twobytes) { unsigned char * tmp = (unsigned char *)twobytes; unsigned int i; i = tmp[1]; tmp[1] = tmp[0]; tmp[0] = i; return; }
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 pooh.tif Color Image. 239 x 184 pixels.
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [501] seville & od -A x -t x1 pooh.tif | more d 4d 00 2a fe ef b da e e e b a f0 01 1b a f8 01 1c b c ea bb d ea
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [501] seville & od -A x -t x1 pooh.tif | more d 4d 00 2a fe ef b da e e e b a f0 01 1b a f8 01 1c b c ea bb d ea Big-Endian or Little-Endian 4d4d = Big 4949 = Little
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [501] seville & od -A x -t x1 pooh.tif | more d 4d 00 2a fe ef b da e e e b a f0 01 1b a f8 01 1c b c ea bb d ea Magic Number = 42 (0x2a)
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [501] seville & od -A x -t x1 pooh.tif | more d 4d 00 2a fe ef b da e e e b a f0 01 1b a f8 01 1c b c ea bb d ea Address of the Image File Directory (IFD). Must begin on a WORD boundary
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [501] seville & od -A x -t x1 pooh.tif | more d 4d 00 2a fe ef b da e e e b a f0 01 1b a f8 01 1c b c ea bb d ea Address of the Image File Directory (IFD). Must begin on a WORD boundary
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [501] seville & od -A x -t x1 pooh.tif | more d 4d 00 2a fe ef b da e e e b a f0 01 1b a f8 01 1c b c ea bb d ea IFD – all data pertaining to the characteristics of the image.
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e e e b a f0 01 1b f8 01 1c 00000a b ea c bb ea d f 6f e 64 First two bytes: the count, that is, the number of entries in the IFD. Entries are sorted by TAG, in ascending numerical order.
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e e e b a f0 01 1b f8 01 1c 00000a b ea c bb ea d f 6f e 64 Next, the IFD Entries. Each is 12 Bytes long.
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e e e b a f0 01 1b f8 01 1c 00000a b ea c bb ea d f 6f e 64 Next, the IFD Entries. Each is 12 Bytes long. Bytes 0-1: The TAG that Identifies the field.
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e e e b a f0 01 1b f8 01 1c 00000a b ea c bb ea d f 6f e 64 Next, the IFD Entries. Each is 12 Bytes long. Bytes 0-1: The TAG that Identifies the field. Bytes 2-3: The Type of the field. Types: 1 = Byte (8 bit) 2 = Ascii (8 bit) 3 = Short (2 byte) 4 = Long (4 byte) 5 = Rational (2 Longs)
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e e e b a f0 01 1b f8 01 1c 00000a b ea c bb ea d f 6f e 64 Next, the IFD Entries. Each is 12 Bytes long. Bytes 0-1: The TAG that Identifies the field. Bytes 2-3: The Type of the field. Bytes 4-7: The Count (no. of values) Types: 1 = Byte (8 bit) 2 = Ascii (8 bit) 3 = Short (2 byte) 4 = Long (4 byte) 5 = Rational (2 Longs)
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e e e b a f0 01 1b f8 01 1c 00000a b ea c bb ea d f 6f e 64 Bytes 8-11: the Value Offset. The offset in bytes of the value for the field. Must begin on a word boundary. Can point anywhere in the file.
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e e e b a f0 01 1b f8 01 1c 00000a b ea c bb ea d f 6f e 64 Bytes 8-11: the Value Offset. The offset in bytes of the value for the field. Must begin on a word boundary. Can point anywhere in the file. If the Value fits into 4 bytes (i.e. is 1 byte and has count les than 5, is a short and has count less than 2, or is one long, etc.) THEN the Value will be stored in bytes 8-11, and will be left justified.
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e e e b a f0 01 1b f8 01 1c 00000a b ea c bb ea d f 6f e 64 ImageWidth
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e e e b a f0 01 1b f8 01 1c 00000a b ea c bb ea d f 6f e 64 ImageLength
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e [503] seville & od -A x -t x1 -j 0xda pooh.tif | more f 6f e a fc a BitsPerSample
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 Tiff Image Data Organized into strips. Three fields govern this: RowsPerStrip, StripOffsets, and StripBytecounts. Strips per Image =
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 Tiff Image Data Each strip contains a number of rows of image data. Putting them all together gives you the image data for the image. RowPerStrip = How many rows for each strip StripOffsets = The location of each of the strips StripByteCounts = The number of bytes in each strip
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [502] seville & od -A x -t x1 -j 0x8 pooh.tif | more fe ef b da e e e b a [504] seville & od -A x -t x1 -j 0x32e pooh.tif | more bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb aa ee bb
CS 258 Introduction to Graphics Bobby Bodenheimer Fall 2003 [507] seville & od -A x -t x1 play2.tif | more a f a8 a3 8a 10 4b 0c a a 08 0a f 9f 9f 9f 9f f e 9e 9e 99 9f 9f 9f 86 9f 9f 9f 9f 9f [509] seville & od -A x -t x1 -j 0x40008 play2.tif b c Little Endian