2007.07.20 20:14 "[Tiff] Reading the strip byte count array", by Christian Henning

2007.07.23 11:03 "Re: [Tiff] Reading the strip byte count array", by Andrey Kiselev

Christian,

On Fri, Jul 20, 2007 at 04:14:04PM -0400, Christian Henning wrote:

Hi there, I have a problem getting the strip byte counts array. If I read a tiff file using the tiff_viewer it tells me the strip byte counts count is 222. First of all I don't understand how this number is calculated.

Taking the documentation it says:

strips_per_image = floor( image_length + rows_per_strip - 1 ) / rows_per_strip;

No need to calculate this nubmer yourself. There is a special function to get count:

 tstrip_t nstrips = TIFFNumberOfStrips(tif);

First of all, what is image_length. Is that somewhere defined?

It is a number of rows in image. It can be requested with the following call:

 uint32 height;
 TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);

But even when I use this number the function

uint32 buffer[222];

TIFFGetField( img, TIFFTAG_STRIPBYTECOUNTS, &buffer );

That's wrong. Use the following snippet:

 toff_t* stripbytecounts;
 TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecounts);

I am using toff_t here to be compatible both with libtiff 3.x and 4.x series. In libtiff 3.x it is uint32, in libtiff 4.x it is uint64, but if you are planning to go with one particular branch it is better to use direct type instead of that typedef.

Best regards,

Andrey

--
Andrey V. Kiselev
ICQ# 26871517