3

On the LibTIFF documentation, there is no mention or sample of how to read a 16 bit RGB image. Apparently also, using the scanline functions is required for reading a 16 bit. After a few attempts I couldn't get that to work.

According to this post,

If you want to handle all kind of TIFF image wihout using TIFFReadRGBAImage then you have to detect the image format and use low-level interface such as TIFFReadEncodedStrip and TIFFReadEncodedTile

My end goal is to be able to get 16 bit values for the R,G and B channels, as well as actually know where they are in the image.

In the docs for libtiff they provide this sample code for eading using the strip encoding, however, they don't explain what is in the buf you get or how to make use of it. Can anyone explain how I am supposed to read the 16 bit values from that? Also, is there a way to consistent determine the strip order so I my read image is rendered correct?

TIFF* tif = TIFFOpen("myfile.tif", "r");
if (tif) {
tdata_t buf;
tstrip_t strip;

buf = _TIFFmalloc(TIFFStripSize(tif));
for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++)
    TIFFReadEncodedStrip(tif, strip, buf, (tsize_t) -1);
_TIFFfree(buf);
TIFFClose(tif);
}
Community
  • 1
  • 1
user3765372
  • 281
  • 1
  • 3
  • 14

0 Answers0