
Thread
2006.12.26 10:10 "Re: [Tiff] Interpreting values in tdir_offset of TIFFDirEntry", by Andrey Kiselev
On Wed, Dec 20, 2006 at 02:24:43PM +0100, mikk wrote:
I'm not sure I understand the way of interpreting values stored in the tdir_offset of TIFFDirEntry structure. According to the tiff.h comments for the TIFFDirEntry struct:
"...If the value is 4 bytes or less, then it is placed in the offset field to save space. If the value is less than 4 bytes, it is left-justified in the offset field."
When the IFD entry (a tag) is written into a TIFF file, and the data type size is 2 bytes (fe. TIFF_SHORT), and data length is 2, that makes 4 bytes of data. I assume that the data itself is saved in the tdir_offset field. And what if the data type size is 1 byte (fe. TIFF_ASCII or TIFF_BYTE) and data length is less than or equal to 4? I assume that the data itself is saved in the tdir_offset. Am I right?
You are rigt, it works that way. If you interested how it is implemented in libtiff take a look at the tif_dirread.c module. TIFFFetch*() functions always check whether we have values stored in the offset field itself or we should seek in file to grab them.
Best regards,
Andrey
--
Andrey V. Kiselev
ICQ# 26871517