2005.06.28 14:20 "Re: [Tiff] Simpler interface than strip-oriented interface", by Bob Friesenhahn
I am currently coding an interface to Libtiff which would convert a strip of the tiff image to RGB format. I am using the TIFFReadRGBAStrip API. This works perfectly fine until I find images with only 1 strip and very, very large stripbytecounts (like 4mb or 6mb). I would then have to keep a buffer with this size (4 or 6 mb)since the API needs the whole strip to be passed to it. This is very hard for me since we only have a limited amount of memory.
Is there another way to parse the image?? Im looking for an interface that would accept a smaller data size than the strip, if the strip is too large.
Use TIFFReadScanline(). This returns a single scanline from the strip. Conversion from strips to scanlines is done within libtiff in order to produce scanlines while using a small amount of memory.
This is a much lower-level interface than TIFFReadRGBAStrip() so you have to be prepared to unpack packed pixels and be aware of endian ordering (libtiff presents data for sample sizes evenly divisible by 8 in native endian order).
I also found out about ScanLine but this is not a very reliable interface since it only works if the RowsPerStrip is equal to 1 and if there is no compression. My understanding is correct, am I right?
TIFFReadScanline() works fine for me. For reasonable sized strips, using TIFFReadEncodedStrip() may be faster. TIFFReadEncodedStrip() is even lower level than TIFFReadEncodedStrip(), but it is high enough that the data is uncompressed.
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/