mirror of
https://github.com/boostorg/gil.git
synced 2026-02-18 02:02:09 +00:00
First bit of getting alpha channels saved in TIFF files. The Extra Samples tag is now set.
This commit is contained in:
committed by
Stefan Seefeld
parent
5b2e3ef0c7
commit
85a02eaade
@@ -19,6 +19,8 @@
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <boost/mpl/contains.hpp>
|
||||
|
||||
#include <boost/gil/extension/io/tiff_tags.hpp>
|
||||
|
||||
namespace boost { namespace gil {
|
||||
@@ -58,11 +60,10 @@ protected:
|
||||
|
||||
// get the type of the first channel (heterogeneous pixels might be broken for now!)
|
||||
typedef typename channel_traits< typename element_type< pixel_t >::type >::value_type channel_t;
|
||||
typedef typename color_space_type< View >::type color_space_t;
|
||||
|
||||
if(! this->_info._photometric_interpretation_user_defined )
|
||||
{
|
||||
typedef typename color_space_type< View >::type color_space_t;
|
||||
|
||||
// write photometric interpretion - Warning: This value is rather
|
||||
// subjective. The user should better set this value itself. There
|
||||
// is no way to decide if a image is PHOTOMETRIC_MINISWHITE or
|
||||
@@ -87,6 +88,12 @@ protected:
|
||||
tiff_samples_per_pixel::type samples_per_pixel = num_channels< pixel_t >::value;
|
||||
this->_io_dev.template set_property<tiff_samples_per_pixel>( samples_per_pixel );
|
||||
|
||||
// The other half of the story is that it needs to be premultiplied on the way into the file.
|
||||
if (boost:: mpl:: contains <color_space_t, alpha_t>:: value) { // the pixel type includes alpha_t
|
||||
this->_info._extra_sample_value = EXTRASAMPLE_ASSOCALPHA;
|
||||
this->_info._extra_samples = &(this->_info._extra_sample_value);
|
||||
this->_io_dev.template set_property<tiff_extra_samples>( this->_info._extra_samples );
|
||||
}
|
||||
// write bits per sample
|
||||
// @todo: Settings this value usually requires to write for each sample the bit
|
||||
// value seperately in case they are different, like rgb556.
|
||||
|
||||
@@ -286,6 +286,7 @@ struct image_write_info< tiff_tag, Log >
|
||||
, _tile_length ( 0 )
|
||||
, _x_resolution ( 0 )
|
||||
, _y_resolution ( 0 )
|
||||
, _extra_samples ( 0 )
|
||||
{}
|
||||
|
||||
/// The color space of the image data.
|
||||
@@ -310,7 +311,10 @@ struct image_write_info< tiff_tag, Log >
|
||||
tiff_x_resolution::type _x_resolution;
|
||||
tiff_y_resolution::type _y_resolution;
|
||||
|
||||
/// A log to transcript error and warning messages issued by libtiff.
|
||||
/// Extra Sample type (for alpha)
|
||||
tiff_extra_samples::type _extra_samples;
|
||||
uint16_t _extra_sample_value;
|
||||
/// A log to transcript error and warning messages issued by libtiff.
|
||||
Log _log;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user