diff -rwbBui gil/boost/gil/extension/io/tiff_io.hpp boost/boost/include/boost-1_34/boost/gil/extension/io/tiff_io.hpp --- gil/boost/gil/extension/io/tiff_io.hpp 2007-08-21 12:12:14.000000000 +0100 +++ boost/boost/include/boost-1_34/boost/gil/extension/io/tiff_io.hpp 2007-08-10 13:51:54.000000000 +0100 @@ -23,6 +23,9 @@ #include #include #include +#include +#include +#include #include #include #include "../../gil_all.hpp" @@ -94,6 +115,12 @@ BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); }; template <> +struct tiff_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=8); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); +}; +template <> struct tiff_write_support_private { BOOST_STATIC_CONSTANT(bool,is_supported=true); BOOST_STATIC_CONSTANT(int,bit_depth=16); @@ -106,6 +133,12 @@ BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); }; template <> +struct tiff_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=16); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); +}; +template <> struct tiff_write_support_private { BOOST_STATIC_CONSTANT(bool,is_supported=true); BOOST_STATIC_CONSTANT(int,bit_depth=32); @@ -117,6 +150,12 @@ BOOST_STATIC_CONSTANT(int,bit_depth=32); BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); }; +template <> +struct tiff_write_support_private { + BOOST_STATIC_CONSTANT(bool,is_supported=true); + BOOST_STATIC_CONSTANT(int,bit_depth=32); + BOOST_STATIC_CONSTANT(int,color_type=PHOTOMETRIC_RGB); +}; class tiff_reader { protected: @@ -286,6 +357,27 @@ } }; +template +struct premultiplier_impl + : public default_color_converter_impl { + template // Model PixelConcept + void operator()(const SrcP& src, DstP& dst) const { + get_color (dst) = channel_multiply (get_color (src), get_color (src)); + get_color (dst) = channel_multiply (get_color (src), get_color (src)); + get_color (dst) = channel_multiply (get_color (src), get_color (src)); + get_color (dst) = get_color (src); + } +}; + +struct premultiplier { + template // Model PixelConcept + void operator()(const SrcP& src,DstP& dst) const { + typedef typename color_space_type::type SrcColorSpace; + typedef typename color_space_type::type DstColorSpace; + premultiplier_impl()(src,dst); + } +}; + class tiff_writer { protected: TIFF* _tp; @@ -308,10 +402,20 @@ io_error_if(TIFFSetField(_tp,TIFFTAG_BITSPERSAMPLE, tiff_write_support_private::type, typename color_space_type::type>::bit_depth)!=1); io_error_if(TIFFSetField(_tp,TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(_tp, 0))!=1); + + if (3 < num_channels::value) { + uint16_t alphaStyle = EXTRASAMPLE_ASSOCALPHA; + io_error_if(TIFFSetField(_tp,TIFFTAG_EXTRASAMPLES, 1, & alphaStyle)!=1); + } + + View ccv = color_converted_view (view, premultiplier ()); + View const & outputView = 3 < num_channels::value? ccv: view; + std::vector::type, layout::type> > > row(view.width()); + for (int y=0;y