AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2003.04.28 19:44 "Registering a tag with Adobe", by Robert S. Kissel
2003.04.29 04:26 "Re: Registering a tag with Adobe", by Chris Cox
2003.04.29 16:12 "Newbie Question (StripOffsets/StripByteCount)", by Harring Figueiredo
2003.04.29 16:50 "RE: Newbie Question (StripOffsets/StripByteCount)", by Belshan, James
2003.04.29 17:58 "RE: Newbie Question (StripOffsets/StripByteCount)", by Harring Figueiredo
2003.04.29 19:51 "RE: Newbie Question (StripOffsets/StripByteCount)", by Carter John-jcarte01
2003.04.30 15:08 "RE: Newbie Question (StripOffsets/StripByteCount)", by Harring Figueiredo
2003.04.30 15:19 "RE: Newbie Question (StripOffsets/StripByteCount)", by Carter John-jcarte01

2003.04.29 19:51 "RE: Newbie Question (StripOffsets/StripByteCount)", by Carter John-jcarte01

Hi Harring

I think I'm right in making a correction to your
condition.
I think it should be ( count * size_of_type >= 4)
rather than

( count * size_of_type > 4)

I made that mistake too, and it took me a while to spot it.

also (on slightly related point)
don't forget to cast the ifd_entry.value_offset

such as compression below, switching on ifd_entry.value_offset directly can give you some strange results.

                case COMPRESSION:
                        tiff_data->compression = (TIFF_SHORT)ifd_entry.value_offset;
                        if(DEBUG&LOAD_PAGE_DEBUG){
                                printf("COMPRESSION:\n");
                                switch(tiff_data->compression){
                                        case 1:

                                                printf("        Image is not compressed\n");
                                                break;
                                        case 2:
                                                printf("        Uses 1d Huffman run length encoding\n");
                                                break;
                                        case 3:
                                                printf("        T4 Bilevel compression\n");
                                                break;
                                        case 4:
                                                printf("        T6 Bilevel compression\n");
                                                break;
                                        case 5:
                                                printf("        LZW compression\n");
                                                break;
                                        case 6:
                                                printf("        JPEG compression\n");
                                                break;
                                        case 32773:
                                                printf("        PackBits on Raster image data\n");
                                                break;
                                        default:
                                                printf("        No case for compression type %d\n",
                                                                ifd_entry.value_offset);
                                                printf("        in file %s %d\n",__FILE__,__LINE__);
                                                break;

                                }
                        }
                        break;

-----Original Message-----

From: Harring Figueiredo [mailto:harringf@yahoo.com]
Sent: 29 April 2003 18:59
To: Belshan, James (E52); tiff@olympiakos.com

Subject: RE: Newbie Question (StripOffsets/StripByteCount)

  James,

Thanks for the reply.

I understand the offset concept when the data does not fit on the LONG value field ( count * size_of_type > 4) means that the value holds the offset. In fact, I already have a Java TIFF dump that matches exactly with the C counterpart ( except that mine still does not handle multipage).

Thanks again for clarifying how to get the strip data. I will do the way you are saying.

 Harring.

--- "Belshan, James (E52)" <belshan_jl@nns.com> wrote:

Hope I don't say anything that's incorrect... But here goes.

How you interpret the ValueOffset (VO) field depends on how much and what type of numbers are in the tag. If all of the tag data will fit in the VO field, it puts it there, otherwise VO is a LONG pointer to the data location. If that's the case, then you would move to that point in the file, and read the number and type of Values specified in the tag. In your case, since the StipOffset and StripByteCount tags only have 1 value, it fits in the VO field. So you would move to byte 8 in the file and read 11544 bytes of data to get your image.

If you had more than 1 strip, (say 5 strips) then StripOffsets would have 5 values (and so wouldn't fit in the VO field), and the StripOffsets VO would point you where to go to read 5 LONG offsets. You would then go to EACH of the 5 byte locations and read the proper # of bytes for that strip. StripByteCounts would also have 5 values to tell how long each of the 5 strips are.

Page 16 of the TIFF Rev 6.0 tells you that the VO field is 4 bytes long, so it will fit 2 SHORTS or 1 LONG. An example of a tag that doesn't fit in the VO field is the RATIONAL resolutions that tiffdump is showing you. RATIONALS are 8 bytes, and so don't fit in the VO field. tiffdump is actually following an offset in the VO, and reading 8 bytes to make the RATIONAL.

Hope this helps,