Boost logo

Boost :

Subject: [boost] [gil new_io] tiff alpha channel support
From: Erik Hvatum (ice.rikh_at_[hidden])
Date: 2011-04-17 18:36:45


gil new_io does not support tiff alpha channel. Is support planned? If not, I'll attempt to add it and submit a patch if successful.


I am using the latest code from the gil-contributions googlecode SVN repository. The following causes a crash when "tifffile.tif" is interleaved 32-bit rgba (ie 8*4 bits, including the alpha channel):

argb8_image_t image;
read_and_convert_image("tifffile.tif", image, tiff_tag());

If "tifffile.tif" is planar instead of interleaved, no crash occurs. However, the image is not loaded correctly - all channels are filled with the same values, causing the image to apparently be grayscale.

"tifffile.tif" stored without an alpha channel loads correctly, but the alpha channel is essential for my application.

Around line 237 of io_new/formats/tiff/read.hpp, I see that we are reading into an rgb8_view_t for 8 bit per sample images, so we're obviously not going to retain alpha channel data even if it is read correctly. Additionally, TIFFTAG_SAMPLES_PER_PIXEL is read but not respected.

To avoid crashes for tiff images with extra channels, row_buffer_helper must be aware of TIFFTAG_SAMPLES_PER_PIXEL. So that the alpha channel is retained for RGBA images, in the PHOTOMETRIC_RGB case near line 237, if TIFFTAG_SAMPLES_PER_PIXEL is 4, we should read into an rgba*_view_t.

Boost list run by bdawes at, gregod at, cpdaniel at, john at