2010.04.09 13:38 "[Tiff] TIFFReadEncodedStrip issue with FreeImage on 64bit Linux", by Christian Heimes

Hello,

I'm using FreeImage [1] to process and convert TIFF images. FreeImage is a library that amongst others wraps several image library in a powerful and convenient API. The latest version of FreeImage contains libtiff 3.9.2.

For a while I'm fighting with a bug that affects loading of compressed TIFF images on 64bit Linux. I'm not able to reproduce the bug on 32bit Linux nor Windows (32 and 64bit). Also I'm unable to figure the bug out on my own but I was able to limit the issue to a few lines of code. Maybe somebody here with an insight in the libtiff API is able to give me a hint.

You can see the effect of the bug at [2]. The original image is a white 1bpp TIFF with a vertical line of dots. I used tiffcp to compress the image. The first image is created from an uncompressed 1bpp TIFF, the second from a G3 compressed copy, the last from a G4 compressed copy. As you can see the images created from compressed TIFFs contain noise. Several debugging sessions have revealed the code at [3] between line 1651 and 1673 as the most promising location of the bug. I suspect that FreeImage doesn't calculates the strip correctly. I've summed up my findings at [4], too.

Thanks!
Christian

[1] http://freeimage.sourceforge.net/
[2] http://picasaweb.google.de/tiran79/Tiff

[3] http://freeimage.cvs.sourceforge.net/viewvc/freeimage/FreeImage/Source/FreeImage/PluginTIFF.cpp?revision=1.52&view=markup#l_1651 [4] http://sourceforge.net/tracker/?func=detail&aid=2882437&group_id=11504&atid=111504