2001.12.12 20:23 "jpeg in tiff problem", by Eric Hamrick

2001.12.14 14:23 "Re: jpeg in tiff problem", by Frank Warmerdam

The TifStripSize(tif) is reporting 1402500 and this was what I was allocating for the buffer I'm passing to TIFFReadEncodedStrip. I increased the memory being allocated 100x and the function passed without crashing this time through. However the image I received was barely discernable but I could tell what it was supposed to be and also 1/4 of its right half was black. TIFFReadEncodedStrip should only be returning the RGB values, correct?

Eric,

The JPEG data is in YCbCr format. In this format you get Y component for each pixel, and a Cb and Cr component for a subset of pixels based on the horizontal and vertical sampling rates.

This is rather involved to compose back into a useful RGBA image, so normally I just use the RGBA interface (ie. TIFFReadRGBAImage()) for such files. This is what tiff2rgba uses.

I would suggest you use that now, instead of TIFFReadEncodedStrip().

Of course, if the TIFFStripSize() is being returned wrong, I may have just been lucky that TIFFReadRGBAImage() worked for me. It is going to be hard to make TIFFStripSize() do the right thing given that the correct sampling rate isn't learned till reading of the jpeg stream begins.

I hate these screwed up files!

Best regards,

---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent