update boost
This commit is contained in:
@@ -10,15 +10,15 @@
|
||||
|
||||
#include <boost/gil/extension/io/tiff/tags.hpp>
|
||||
#include <boost/gil/extension/io/tiff/detail/log.hpp>
|
||||
|
||||
#include <boost/gil/detail/mp11.hpp>
|
||||
#include <boost/gil/io/base.hpp>
|
||||
#include <boost/gil/io/device.hpp>
|
||||
|
||||
#include <boost/mpl/size.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
// taken from jpegxx - https://bitbucket.org/edd/jpegxx/src/ea2492a1a4a6/src/ijg_headers.hpp
|
||||
#ifndef BOOST_GIL_EXTENSION_IO_TIFF_C_LIB_COMPILED_AS_CPLUSPLUS
|
||||
@@ -66,15 +66,13 @@ template <> struct get_property_f <2>
|
||||
// Specialisation for multi-valued properties. @todo: add one of
|
||||
// these for the three-parameter fields too.
|
||||
template <typename Property>
|
||||
bool call_me(typename Property:: type & vs, std::shared_ptr<TIFF>& file) const
|
||||
bool call_me(typename Property::type& vs, std::shared_ptr<TIFF>& file) const
|
||||
{
|
||||
typename mpl:: at <typename Property:: arg_types, mpl::int_<0> >:: type length;
|
||||
typename mpl:: at <typename Property:: arg_types, mpl::int_<1> >:: type pointer;
|
||||
if (1 == TIFFGetFieldDefaulted( file.get()
|
||||
, Property:: tag
|
||||
, & length
|
||||
, & pointer)) {
|
||||
std:: copy_n (static_cast <typename Property:: type:: const_pointer> (pointer), length, std:: back_inserter (vs));
|
||||
mp11::mp_at<typename Property::arg_types, std::integral_constant<int, 0>> length;
|
||||
mp11::mp_at<typename Property::arg_types, std::integral_constant<int, 1>> pointer;
|
||||
if (1 == TIFFGetFieldDefaulted(file.get(), Property:: tag, & length, & pointer))
|
||||
{
|
||||
std:: copy_n(static_cast<typename Property::type::const_pointer>(pointer), length, std:: back_inserter(vs));
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
@@ -106,12 +104,12 @@ template <> struct set_property_f <2>
|
||||
inline
|
||||
bool call_me(typename Property:: type const & values, std::shared_ptr<TIFF>& file) const
|
||||
{
|
||||
typename mpl:: at <typename Property:: arg_types, mpl::int_<0> >:: type const length = values. size ();
|
||||
typename mpl:: at <typename Property:: arg_types, mpl::int_<1> >:: type const pointer = & (values. front ());
|
||||
return (1 == TIFFSetField( file.get()
|
||||
, Property:: tag
|
||||
, length
|
||||
, pointer));
|
||||
using length_t = mp11::mp_at_c<typename Property::arg_types, 0>;
|
||||
auto const length = static_cast<length_t>(values.size());
|
||||
|
||||
using pointer_t = mp11::mp_at_c<typename Property::arg_types, 1>;
|
||||
auto const pointer = static_cast<pointer_t>(&(values.front()));
|
||||
return (1 == TIFFSetField( file.get(), Property:: tag, length, pointer));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -132,7 +130,7 @@ public:
|
||||
template <typename Property>
|
||||
bool get_property( typename Property::type& value )
|
||||
{
|
||||
return get_property_f <mpl:: size <typename Property:: arg_types>::value > ().template call_me<Property>(value, _tiff_file);
|
||||
return get_property_f<mp11::mp_size<typename Property::arg_types>::value>().template call_me<Property>(value, _tiff_file);
|
||||
}
|
||||
|
||||
template <typename Property>
|
||||
@@ -140,7 +138,7 @@ public:
|
||||
bool set_property( const typename Property::type& value )
|
||||
{
|
||||
// http://www.remotesensing.org/libtiff/man/TIFFSetField.3tiff.html
|
||||
return set_property_f <mpl:: size <typename Property:: arg_types>::value > ().template call_me<Property> (value, _tiff_file);
|
||||
return set_property_f<mp11::mp_size<typename Property::arg_types>::value>().template call_me<Property>(value, _tiff_file);
|
||||
}
|
||||
|
||||
// TIFFIsByteSwapped returns a non-zero value if the image data was in a different
|
||||
@@ -195,7 +193,7 @@ public:
|
||||
{
|
||||
io_error_if( TIFFReadScanline( _tiff_file.get()
|
||||
, reinterpret_cast< tdata_t >( &buffer.front() )
|
||||
, (uint32) row
|
||||
, static_cast<std::uint32_t>( row )
|
||||
, plane ) == -1
|
||||
, "Read error."
|
||||
);
|
||||
@@ -208,7 +206,7 @@ public:
|
||||
{
|
||||
io_error_if( TIFFReadScanline( _tiff_file.get()
|
||||
, reinterpret_cast< tdata_t >( buffer )
|
||||
, (uint32) row
|
||||
, static_cast<std::uint32_t>( row )
|
||||
, plane ) == -1
|
||||
, "Read error."
|
||||
);
|
||||
@@ -224,9 +222,9 @@ public:
|
||||
{
|
||||
if( TIFFReadTile( _tiff_file.get()
|
||||
, reinterpret_cast< tdata_t >( &buffer.front() )
|
||||
, (uint32) x
|
||||
, (uint32) y
|
||||
, (uint32) z
|
||||
, static_cast< std::uint32_t >( x )
|
||||
, static_cast< std::uint32_t >( y )
|
||||
, static_cast< std::uint32_t >( z )
|
||||
, plane
|
||||
) == -1 )
|
||||
{
|
||||
@@ -237,9 +235,9 @@ public:
|
||||
}
|
||||
|
||||
template< typename Buffer >
|
||||
void write_scaline( Buffer& buffer
|
||||
, uint32 row
|
||||
, tsample_t plane
|
||||
void write_scaline( Buffer& buffer
|
||||
, std::uint32_t row
|
||||
, tsample_t plane
|
||||
)
|
||||
{
|
||||
io_error_if( TIFFWriteScanline( _tiff_file.get()
|
||||
@@ -251,9 +249,9 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
void write_scaline( byte_t* buffer
|
||||
, uint32 row
|
||||
, tsample_t plane
|
||||
void write_scaline( byte_t* buffer
|
||||
, std::uint32_t row
|
||||
, tsample_t plane
|
||||
)
|
||||
{
|
||||
io_error_if( TIFFWriteScanline( _tiff_file.get()
|
||||
@@ -266,11 +264,11 @@ public:
|
||||
}
|
||||
|
||||
template< typename Buffer >
|
||||
void write_tile( Buffer& buffer
|
||||
, uint32 x
|
||||
, uint32 y
|
||||
, uint32 z
|
||||
, tsample_t plane
|
||||
void write_tile( Buffer& buffer
|
||||
, std::uint32_t x
|
||||
, std::uint32_t y
|
||||
, std::uint32_t z
|
||||
, tsample_t plane
|
||||
)
|
||||
{
|
||||
if( TIFFWriteTile( _tiff_file.get()
|
||||
@@ -303,8 +301,8 @@ public:
|
||||
)
|
||||
{
|
||||
bool result = true;
|
||||
uint32 tw = static_cast< uint32 >( width );
|
||||
uint32 th = static_cast< uint32 >( height );
|
||||
std::uint32_t tw = static_cast< std::uint32_t >( width );
|
||||
std::uint32_t th = static_cast< std::uint32_t >( height );
|
||||
|
||||
TIFFDefaultTileSize( _tiff_file.get()
|
||||
, &tw
|
||||
@@ -432,45 +430,55 @@ private:
|
||||
|
||||
/*
|
||||
template< typename T, typename D >
|
||||
struct is_adaptable_input_device< tiff_tag, T, D > : mpl::false_{};
|
||||
struct is_adaptable_input_device< tiff_tag, T, D > : std::false_type {};
|
||||
*/
|
||||
|
||||
template< typename FormatTag >
|
||||
struct is_adaptable_input_device< FormatTag
|
||||
, TIFF*
|
||||
, void
|
||||
>
|
||||
: mpl::true_
|
||||
template<typename FormatTag>
|
||||
struct is_adaptable_input_device<FormatTag, TIFF*, void> : std::true_type
|
||||
{
|
||||
using device_type = file_stream_device<FormatTag>;
|
||||
};
|
||||
|
||||
template< typename FormatTag >
|
||||
struct is_adaptable_output_device< FormatTag
|
||||
, TIFF*
|
||||
, void
|
||||
>
|
||||
: mpl::true_
|
||||
template<typename FormatTag>
|
||||
struct is_adaptable_output_device<FormatTag, TIFF*, void> : std::true_type
|
||||
{
|
||||
using device_type = file_stream_device<FormatTag>;
|
||||
};
|
||||
|
||||
|
||||
template < typename Channel > struct sample_format : public mpl::int_<SAMPLEFORMAT_UINT> {};
|
||||
template<> struct sample_format<uint8_t> : public mpl::int_<SAMPLEFORMAT_UINT> {};
|
||||
template<> struct sample_format<uint16_t> : public mpl::int_<SAMPLEFORMAT_UINT> {};
|
||||
template<> struct sample_format<uint32_t> : public mpl::int_<SAMPLEFORMAT_UINT> {};
|
||||
template<> struct sample_format<float32_t> : public mpl::int_<SAMPLEFORMAT_IEEEFP> {};
|
||||
template<> struct sample_format<double> : public mpl::int_<SAMPLEFORMAT_IEEEFP> {};
|
||||
template<> struct sample_format<int8_t> : public mpl::int_<SAMPLEFORMAT_INT> {};
|
||||
template<> struct sample_format<int16_t> : public mpl::int_<SAMPLEFORMAT_INT> {};
|
||||
template<> struct sample_format<int32_t> : public mpl::int_<SAMPLEFORMAT_INT> {};
|
||||
template <typename Channel>
|
||||
struct sample_format : std::integral_constant<int, SAMPLEFORMAT_UINT> {};
|
||||
template<>
|
||||
struct sample_format<uint8_t> : std::integral_constant<int, SAMPLEFORMAT_UINT> {};
|
||||
template<>
|
||||
struct sample_format<uint16_t> : std::integral_constant<int, SAMPLEFORMAT_UINT> {};
|
||||
template<>
|
||||
struct sample_format<uint32_t> : std::integral_constant<int, SAMPLEFORMAT_UINT> {};
|
||||
template<>
|
||||
struct sample_format<float32_t> : std::integral_constant<int, SAMPLEFORMAT_IEEEFP> {};
|
||||
template<>
|
||||
struct sample_format<double> : std::integral_constant<int, SAMPLEFORMAT_IEEEFP> {};
|
||||
template<>
|
||||
struct sample_format<int8_t> : std::integral_constant<int, SAMPLEFORMAT_INT> {};
|
||||
template<>
|
||||
struct sample_format<int16_t> : std::integral_constant<int, SAMPLEFORMAT_INT> {};
|
||||
template<>
|
||||
struct sample_format<int32_t> : std::integral_constant<int, SAMPLEFORMAT_INT> {};
|
||||
|
||||
template <typename Channel> struct photometric_interpretation {};
|
||||
template<> struct photometric_interpretation< gray_t > : public mpl::int_< PHOTOMETRIC_MINISBLACK > {};
|
||||
template<> struct photometric_interpretation< rgb_t > : public mpl::int_< PHOTOMETRIC_RGB > {};
|
||||
template<> struct photometric_interpretation< rgba_t > : public mpl::int_< PHOTOMETRIC_RGB > {};
|
||||
template<> struct photometric_interpretation< cmyk_t > : public mpl::int_< PHOTOMETRIC_SEPARATED > {};
|
||||
template <typename Channel>
|
||||
struct photometric_interpretation {};
|
||||
template<>
|
||||
struct photometric_interpretation<gray_t>
|
||||
: std::integral_constant<int, PHOTOMETRIC_MINISBLACK> {};
|
||||
template<>
|
||||
struct photometric_interpretation<rgb_t>
|
||||
: std::integral_constant<int, PHOTOMETRIC_RGB> {};
|
||||
template<>
|
||||
struct photometric_interpretation<rgba_t>
|
||||
: std::integral_constant<int, PHOTOMETRIC_RGB> {};
|
||||
template<>
|
||||
struct photometric_interpretation<cmyk_t>
|
||||
: std::integral_constant<int, PHOTOMETRIC_SEPARATED> {};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace gil
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#define BOOST_GIL_EXTENSION_IO_TIFF_DETAIL_IS_ALLOWED_HPP
|
||||
|
||||
#include <boost/gil/extension/io/tiff/tags.hpp>
|
||||
#include <boost/gil/extension/toolbox/metafunctions/is_bit_aligned.hpp>
|
||||
#include <boost/gil/detail/mp11.hpp>
|
||||
#include <boost/gil/io/base.hpp>
|
||||
|
||||
#include <boost/mpl/for_each.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost { namespace gil { namespace detail {
|
||||
@@ -48,13 +48,13 @@ struct Format_Type
|
||||
Channel,
|
||||
typename std::enable_if
|
||||
<
|
||||
mpl::and_
|
||||
mp11::mp_and
|
||||
<
|
||||
mpl::not_
|
||||
mp11::mp_not
|
||||
<
|
||||
typename is_bit_aligned<typename get_pixel_type<View>::type>::type
|
||||
>,
|
||||
is_unsigned<Channel>
|
||||
std::is_unsigned<Channel>
|
||||
>::value
|
||||
>::type
|
||||
>
|
||||
@@ -70,13 +70,13 @@ struct Format_Type
|
||||
Channel,
|
||||
typename std::enable_if
|
||||
<
|
||||
mpl::and_
|
||||
mp11::mp_and
|
||||
<
|
||||
mpl::not_
|
||||
mp11::mp_not
|
||||
<
|
||||
typename is_bit_aligned<typename get_pixel_type<View>::type>::type
|
||||
>,
|
||||
is_signed<Channel>
|
||||
std::is_signed<Channel>
|
||||
>::value
|
||||
>::type
|
||||
>
|
||||
@@ -92,9 +92,9 @@ struct Format_Type
|
||||
Channel,
|
||||
typename std::enable_if
|
||||
<
|
||||
mpl::and_
|
||||
mp11::mp_and
|
||||
<
|
||||
mpl::not_
|
||||
mp11::mp_not
|
||||
<
|
||||
typename is_bit_aligned<typename get_pixel_type<View>::type>::type
|
||||
>,
|
||||
@@ -107,13 +107,13 @@ struct Format_Type
|
||||
};
|
||||
|
||||
//template< typename Channel >
|
||||
//int format_value( mpl::true_ ) // is_bit_aligned
|
||||
//int format_value( std::true_type ) // is_bit_aligned
|
||||
//{
|
||||
// return SAMPLEFORMAT_UINT;
|
||||
//}
|
||||
//
|
||||
//template< typename Channel >
|
||||
//int format_value( mpl::false_ ) // is_bit_aligned
|
||||
//int format_value( std::false_type ) // is_bit_aligned
|
||||
//{
|
||||
// if( is_unsigned< Channel >::value )
|
||||
// {
|
||||
@@ -137,8 +137,8 @@ struct Format_Type
|
||||
// a pixel_t as template parameter whereas the other is using reference_t.
|
||||
template< typename View >
|
||||
bool compare_channel_sizes( const channel_sizes_t& channel_sizes // in bits
|
||||
, mpl::false_ // is_bit_aligned
|
||||
, mpl::true_ // is_homogeneous
|
||||
, std::false_type // is_bit_aligned
|
||||
, std::true_type // is_homogeneous
|
||||
)
|
||||
{
|
||||
using pixel_t = typename View::value_type;
|
||||
@@ -152,17 +152,14 @@ bool compare_channel_sizes( const channel_sizes_t& channel_sizes // in bits
|
||||
|
||||
template< typename View >
|
||||
bool compare_channel_sizes( const channel_sizes_t& channel_sizes // in bits
|
||||
, mpl::true_ // is_bit_aligned
|
||||
, mpl::true_ // is_homogeneous
|
||||
, std::true_type // is_bit_aligned
|
||||
, std::true_type // is_homogeneous
|
||||
)
|
||||
{
|
||||
using ref_t = typename View::reference;
|
||||
|
||||
using channel_t = typename channel_traits<typename element_type<ref_t>::type>::value_type;
|
||||
channel_t c;
|
||||
|
||||
unsigned int s = detail::unsigned_integral_num_bits< channel_t >::value;
|
||||
|
||||
return ( s == channel_sizes[0] );
|
||||
}
|
||||
|
||||
@@ -197,8 +194,8 @@ struct channel_sizes_type< const bit_aligned_pixel_reference< B, C, L, M > > { u
|
||||
|
||||
template< typename View >
|
||||
bool compare_channel_sizes( channel_sizes_t& channel_sizes // in bits
|
||||
, mpl::true_ // is_bit_aligned
|
||||
, mpl::false_ // is_homogeneous
|
||||
, std::true_type // is_bit_aligned
|
||||
, std::false_type // is_homogeneous
|
||||
)
|
||||
{
|
||||
// loop through all channels and compare
|
||||
@@ -207,14 +204,14 @@ bool compare_channel_sizes( channel_sizes_t& channel_sizes // in bits
|
||||
using cs_t = typename channel_sizes_type<ref_t>::type;
|
||||
|
||||
compare_channel_sizes_fn fn( &channel_sizes.front() );
|
||||
mpl::for_each< cs_t >( fn );
|
||||
mp11::mp_for_each<cs_t>(fn);
|
||||
|
||||
return fn._b;
|
||||
}
|
||||
|
||||
template< typename View >
|
||||
bool is_allowed( const image_read_info< tiff_tag >& info
|
||||
, mpl::true_ // is read_and_no_convert
|
||||
, std::true_type // is read_and_no_convert
|
||||
)
|
||||
{
|
||||
channel_sizes_t channel_sizes( info._samples_per_pixel
|
||||
@@ -243,7 +240,7 @@ bool is_allowed( const image_read_info< tiff_tag >& info
|
||||
|
||||
template< typename View >
|
||||
bool is_allowed( const image_read_info< tiff_tag >& /* info */
|
||||
, mpl::false_ // is read_and_no_convert
|
||||
, std::false_type // is read_and_no_convert
|
||||
)
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
#include <boost/gil/extension/io/tiff/detail/is_allowed.hpp>
|
||||
#include <boost/gil/extension/io/tiff/detail/reader_backend.hpp>
|
||||
|
||||
#include <boost/gil/io/detail/dynamic.hpp>
|
||||
#include <boost/gil/io/base.hpp>
|
||||
#include <boost/gil/io/bit_operations.hpp>
|
||||
#include <boost/gil/io/conversion_policies.hpp>
|
||||
#include <boost/gil/io/device.hpp>
|
||||
#include <boost/gil/io/dynamic_io_new.hpp>
|
||||
#include <boost/gil/io/reader_base.hpp>
|
||||
#include <boost/gil/io/row_buffer_helper.hpp>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
// taken from jpegxx - https://bitbucket.org/edd/jpegxx/src/ea2492a1a4a6/src/ijg_headers.hpp
|
||||
@@ -173,7 +174,7 @@ public:
|
||||
// the tiff type need to compatible. Which means:
|
||||
// color_spaces_are_compatible && channels_are_pairwise_compatible
|
||||
|
||||
using is_read_only = typename is_same
|
||||
using is_read_only = typename std::is_same
|
||||
<
|
||||
ConversionPolicy,
|
||||
detail::read_and_no_convert
|
||||
@@ -208,7 +209,7 @@ private:
|
||||
|
||||
template< typename View >
|
||||
void read( View v
|
||||
, mpl::true_ // is_read_only
|
||||
, std::true_type // is_read_only
|
||||
)
|
||||
{
|
||||
read_data< detail::row_buffer_helper_view< View > >( v, 0 );
|
||||
@@ -216,7 +217,7 @@ private:
|
||||
|
||||
template< typename View >
|
||||
void read( View v
|
||||
, mpl::false_ // is_read_only
|
||||
, std::false_type // is_read_only
|
||||
)
|
||||
{
|
||||
// the read_data function needs to know what gil type the source image is
|
||||
@@ -302,11 +303,13 @@ private:
|
||||
, this->_info._height - this->_settings._top_left.y );
|
||||
|
||||
// read the palette first
|
||||
read_data< detail::row_buffer_helper_view< typename PaletteImage::view_t > >( view( indices ), 0 );
|
||||
read_data< detail::row_buffer_helper_view
|
||||
<
|
||||
typename PaletteImage::view_t>
|
||||
>(view(indices), 0);
|
||||
|
||||
read_palette_image( dst_view
|
||||
, view( indices )
|
||||
, typename is_same< View, rgb16_view_t >::type() );
|
||||
read_palette_image(dst_view, view(indices),
|
||||
typename std::is_same<View, rgb16_view_t>::type());
|
||||
}
|
||||
|
||||
template< typename View
|
||||
@@ -314,7 +317,7 @@ private:
|
||||
>
|
||||
void read_palette_image( const View& dst_view
|
||||
, const Indices_View& indices_view
|
||||
, mpl::true_ // is View rgb16_view_t
|
||||
, std::true_type // is View rgb16_view_t
|
||||
)
|
||||
{
|
||||
tiff_color_map::red_t red = nullptr;
|
||||
@@ -356,7 +359,7 @@ private:
|
||||
inline
|
||||
void read_palette_image( const View& /* dst_view */
|
||||
, const Indices_View& /* indices_view */
|
||||
, mpl::false_ // is View rgb16_view_t
|
||||
, std::false_type // is View rgb16_view_t
|
||||
)
|
||||
{
|
||||
io_error( "User supplied image type must be rgb16_image_t." );
|
||||
@@ -653,7 +656,7 @@ private:
|
||||
|
||||
template< typename Pixel >
|
||||
std::size_t buffer_size( std::size_t width
|
||||
, mpl::false_ // is_bit_aligned
|
||||
, std::false_type // is_bit_aligned
|
||||
)
|
||||
{
|
||||
std::size_t scanline_size_in_bytes = this->_io_dev.get_scanline_size();
|
||||
@@ -669,7 +672,7 @@ private:
|
||||
|
||||
template< typename Pixel >
|
||||
std::size_t buffer_size( std::size_t /* width */
|
||||
, mpl::true_ // is_bit_aligned
|
||||
, std::true_type // is_bit_aligned
|
||||
)
|
||||
{
|
||||
return this->_io_dev.get_scanline_size();
|
||||
@@ -694,7 +697,7 @@ struct tiff_type_format_checker
|
||||
using view_t = typename Image::view_t;
|
||||
|
||||
return is_allowed< view_t >( _info
|
||||
, mpl::true_()
|
||||
, std::true_type()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -742,8 +745,8 @@ public:
|
||||
)
|
||||
{}
|
||||
|
||||
template< typename Images >
|
||||
void apply( any_image< Images >& images )
|
||||
template< typename ...Images >
|
||||
void apply( any_image< Images... >& images )
|
||||
{
|
||||
detail::tiff_type_format_checker format_checker( this->_info );
|
||||
|
||||
@@ -763,8 +766,8 @@ public:
|
||||
, parent_t
|
||||
> op( this );
|
||||
|
||||
apply_operation( view( images )
|
||||
, op
|
||||
variant2::visit( op
|
||||
, view( images )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
}
|
||||
|
||||
/// Check if image is large enough.
|
||||
void check_image_size( const point_t& img_dim )
|
||||
void check_image_size( point_t const& img_dim )
|
||||
{
|
||||
if( _settings._dim.x > 0 )
|
||||
{
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
#include <boost/gil/color_base.hpp>
|
||||
#include <boost/gil/io/base.hpp>
|
||||
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost{ namespace gil {
|
||||
|
||||
@@ -35,20 +34,16 @@ struct tiff_write_support : write_support_true
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template< typename Pixel >
|
||||
struct is_read_supported< Pixel
|
||||
, tiff_tag
|
||||
>
|
||||
: mpl::bool_< detail::tiff_read_support::is_supported > {};
|
||||
|
||||
template< typename Pixel >
|
||||
struct is_write_supported< Pixel
|
||||
, tiff_tag
|
||||
>
|
||||
: mpl::bool_< detail::tiff_write_support::is_supported >
|
||||
template<typename Pixel>
|
||||
struct is_read_supported<Pixel, tiff_tag>
|
||||
: std::integral_constant<bool, detail::tiff_read_support::is_supported>
|
||||
{};
|
||||
|
||||
} // namespace gil
|
||||
} // namespace boost
|
||||
template<typename Pixel>
|
||||
struct is_write_supported<Pixel, tiff_tag>
|
||||
: std::integral_constant<bool, detail::tiff_write_support::is_supported>
|
||||
{};
|
||||
|
||||
}} // namespace boost::gil
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
#include <boost/gil/premultiply.hpp>
|
||||
#include <boost/gil/io/base.hpp>
|
||||
#include <boost/gil/io/device.hpp>
|
||||
#include <boost/gil/io/dynamic_io_new.hpp>
|
||||
#include <boost/gil/io/detail/dynamic.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
extern "C" {
|
||||
@@ -39,7 +41,8 @@ template <typename PixelReference>
|
||||
struct my_interleaved_pixel_iterator_type_from_pixel_reference
|
||||
{
|
||||
private:
|
||||
using pixel_t = typename remove_reference<PixelReference>::type::value_type;
|
||||
using pixel_t = typename std::remove_reference<PixelReference>::type::value_type;
|
||||
|
||||
public:
|
||||
using type = typename iterator_type_from_pixel
|
||||
<
|
||||
@@ -162,7 +165,7 @@ private:
|
||||
template<typename View>
|
||||
void write_bit_aligned_view_to_dev( const View& view
|
||||
, const std::size_t row_size_in_bytes
|
||||
, const mpl::true_& // has_alpha
|
||||
, const std::true_type& // has_alpha
|
||||
)
|
||||
{
|
||||
byte_vector_t row( row_size_in_bytes );
|
||||
@@ -181,7 +184,7 @@ private:
|
||||
|
||||
|
||||
this->_io_dev.write_scaline( row
|
||||
, (uint32) y
|
||||
, static_cast<std::uint32_t>( y )
|
||||
, 0
|
||||
);
|
||||
|
||||
@@ -192,7 +195,7 @@ private:
|
||||
template<typename View>
|
||||
void write_bit_aligned_view_to_dev( const View& view
|
||||
, const std::size_t row_size_in_bytes
|
||||
, const mpl::false_& // has_alpha
|
||||
, const std::false_type& // has_alpha
|
||||
)
|
||||
{
|
||||
byte_vector_t row( row_size_in_bytes );
|
||||
@@ -209,7 +212,7 @@ private:
|
||||
|
||||
|
||||
this->_io_dev.write_scaline( row
|
||||
, (uint32) y
|
||||
, static_cast<std::uint32_t>( y )
|
||||
, 0
|
||||
);
|
||||
|
||||
@@ -222,11 +225,11 @@ private:
|
||||
template< typename View >
|
||||
void write_data( const View& view
|
||||
, std::size_t row_size_in_bytes
|
||||
, const mpl::true_& // bit_aligned
|
||||
, const std::true_type& // bit_aligned
|
||||
)
|
||||
{
|
||||
using colour_space_t = typename color_space_type<typename View::value_type>::type;
|
||||
using has_alpha_t = mpl::bool_<mpl::contains<colour_space_t, alpha_t>::value>;
|
||||
using has_alpha_t = mp11::mp_contains<colour_space_t, alpha_t>;
|
||||
|
||||
write_bit_aligned_view_to_dev(view, row_size_in_bytes, has_alpha_t());
|
||||
}
|
||||
@@ -235,7 +238,7 @@ private:
|
||||
void write_tiled_data( const View& view
|
||||
, tiff_tile_width::type tw
|
||||
, tiff_tile_length::type th
|
||||
, const mpl::true_& // bit_aligned
|
||||
, const std::true_type& // bit_aligned
|
||||
)
|
||||
{
|
||||
byte_vector_t row( this->_io_dev.get_tile_size() );
|
||||
@@ -249,7 +252,7 @@ private:
|
||||
template< typename View >
|
||||
void write_data( const View& view
|
||||
, std::size_t
|
||||
, const mpl::false_& // bit_aligned
|
||||
, const std::false_type& // bit_aligned
|
||||
)
|
||||
{
|
||||
std::vector< pixel< typename channel_type< View >::type
|
||||
@@ -271,7 +274,7 @@ private:
|
||||
);
|
||||
|
||||
this->_io_dev.write_scaline( row_addr
|
||||
, (uint32) y
|
||||
, static_cast<std::uint32_t>( y )
|
||||
, 0
|
||||
);
|
||||
|
||||
@@ -283,7 +286,7 @@ private:
|
||||
void write_tiled_data( const View& view
|
||||
, tiff_tile_width::type tw
|
||||
, tiff_tile_length::type th
|
||||
, const mpl::false_& // bit_aligned
|
||||
, const std::false_type& // bit_aligned
|
||||
)
|
||||
{
|
||||
byte_vector_t row( this->_io_dev.get_tile_size() );
|
||||
@@ -302,7 +305,7 @@ private:
|
||||
>
|
||||
void write_tiled_view_to_dev( const View& view
|
||||
, IteratorType it
|
||||
, const mpl::true_& // has_alpha
|
||||
, const std::true_type& // has_alpha
|
||||
)
|
||||
{
|
||||
auto pm_view = premultiply_view <typename View:: value_type>( view );
|
||||
@@ -319,7 +322,7 @@ private:
|
||||
>
|
||||
void write_tiled_view_to_dev( const View& view
|
||||
, IteratorType it
|
||||
, const mpl::false_& // has_alpha
|
||||
, const std::false_type& // has_alpha
|
||||
)
|
||||
{
|
||||
std::copy( view.begin()
|
||||
@@ -359,7 +362,7 @@ private:
|
||||
);
|
||||
|
||||
using colour_space_t = typename color_space_type<typename View::value_type>::type;
|
||||
using has_alpha_t = mpl::bool_<mpl::contains<colour_space_t, alpha_t>::value>;
|
||||
using has_alpha_t = mp11::mp_contains<colour_space_t, alpha_t>;
|
||||
|
||||
write_tiled_view_to_dev(tile_subimage_view, it, has_alpha_t());
|
||||
}
|
||||
@@ -391,8 +394,8 @@ private:
|
||||
}
|
||||
|
||||
this->_io_dev.write_tile( row
|
||||
, static_cast< uint32 >( j )
|
||||
, static_cast< uint32 >( i )
|
||||
, static_cast< std::uint32_t >( j )
|
||||
, static_cast< std::uint32_t >( i )
|
||||
, 0
|
||||
, 0
|
||||
);
|
||||
@@ -428,14 +431,14 @@ public:
|
||||
)
|
||||
{}
|
||||
|
||||
template< typename Views >
|
||||
void apply( const any_image_view< Views >& views )
|
||||
template< typename ...Views >
|
||||
void apply( const any_image_view< Views... >& views )
|
||||
{
|
||||
detail::dynamic_io_fnobj< detail::tiff_write_is_supported
|
||||
, parent_t
|
||||
> op( this );
|
||||
|
||||
apply_operation( views, op );
|
||||
variant2::visit( op, views );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <boost/gil/extension/io/tiff/tags.hpp>
|
||||
#include <boost/gil/extension/io/tiff/detail/device.hpp>
|
||||
|
||||
#include <boost/mpl/contains.hpp>
|
||||
#include <boost/gil/detail/mp11.hpp>
|
||||
|
||||
namespace boost { namespace gil {
|
||||
|
||||
@@ -78,10 +78,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 );
|
||||
|
||||
if (mpl:: contains <color_space_t, alpha_t>:: value) {
|
||||
if /*constexpr*/ (mp11::mp_contains<color_space_t, alpha_t>::value)
|
||||
{
|
||||
std:: vector <uint16_t> extra_samples {EXTRASAMPLE_ASSOCALPHA};
|
||||
this->_io_dev.template set_property<tiff_extra_samples>( 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.
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
|
||||
#include <boost/gil/extension/io/tiff/detail/log.hpp>
|
||||
|
||||
#include <boost/gil/detail/mp11.hpp>
|
||||
#include <boost/gil/io/base.hpp>
|
||||
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
// taken from jpegxx - https://bitbucket.org/edd/jpegxx/src/ea2492a1a4a6/src/ijg_headers.hpp
|
||||
#ifndef BOOST_GIL_EXTENSION_IO_TIFF_C_LIB_COMPILED_AS_CPLUSPLUS
|
||||
@@ -44,7 +45,7 @@ struct tiff_property_base : property_base< T >
|
||||
/// this property:
|
||||
/// http://www.remotesensing.org/libtiff/man/TIFFGetField.3tiff.html
|
||||
/// http://www.remotesensing.org/libtiff/man/TIFFSetField.3tiff.html
|
||||
using arg_types = mpl::vector<typename property_base<unsigned short>::type>;
|
||||
using arg_types = mp11::mp_list<typename property_base<unsigned short>::type>;
|
||||
};
|
||||
|
||||
/// baseline tags
|
||||
@@ -153,9 +154,9 @@ struct tiff_color_map
|
||||
};
|
||||
|
||||
/// Defines type for extra samples property.
|
||||
struct tiff_extra_samples : tiff_property_base<std:: vector <uint16_t>, TIFFTAG_EXTRASAMPLES>
|
||||
struct tiff_extra_samples : tiff_property_base<std::vector<uint16_t>, TIFFTAG_EXTRASAMPLES>
|
||||
{
|
||||
using arg_types = mpl::vector<uint16_t, uint16_t const *>;
|
||||
using arg_types = mp11::mp_list<uint16_t, uint16_t const*>;
|
||||
};
|
||||
|
||||
/// Defines type for copyright property.
|
||||
@@ -182,10 +183,9 @@ struct tiff_tile_width : tiff_property_base< long, TIFFTAG_TILEWIDTH > {};
|
||||
struct tiff_tile_length : tiff_property_base< long, TIFFTAG_TILELENGTH > {};
|
||||
|
||||
/// Defines the page to read in a multipage tiff file.
|
||||
#include <boost/mpl/integral_c.hpp>
|
||||
struct tiff_directory : property_base< tdir_t >
|
||||
{
|
||||
using default_value = boost::mpl::integral_c<type, 0>;
|
||||
using default_value = std::integral_constant<type, 0>;
|
||||
};
|
||||
|
||||
/// Non-baseline tags
|
||||
@@ -193,7 +193,7 @@ struct tiff_directory : property_base< tdir_t >
|
||||
/// Defines type for icc profile property.
|
||||
struct tiff_icc_profile : tiff_property_base<std::vector<uint8_t>, TIFFTAG_ICCPROFILE>
|
||||
{
|
||||
using arg_types = mpl::vector<uint32_t, void const *>;
|
||||
using arg_types = mp11::mp_list<uint32_t, void const*>;
|
||||
};
|
||||
|
||||
/// Read information for tiff images.
|
||||
@@ -270,7 +270,7 @@ template<>
|
||||
struct image_read_settings< tiff_tag > : public image_read_settings_base
|
||||
{
|
||||
/// Default constructor
|
||||
image_read_settings< tiff_tag >()
|
||||
image_read_settings()
|
||||
: image_read_settings_base()
|
||||
, _directory( tiff_directory::default_value::value )
|
||||
{}
|
||||
@@ -279,8 +279,8 @@ struct image_read_settings< tiff_tag > : public image_read_settings_base
|
||||
/// \param top_left Top left coordinate for reading partial image.
|
||||
/// \param dim Dimensions for reading partial image.
|
||||
/// \param directory Defines the page to read in a multipage tiff file.
|
||||
image_read_settings( const point_t& top_left
|
||||
, const point_t& dim
|
||||
image_read_settings( point_t const& top_left
|
||||
, point_t const& dim
|
||||
, const tiff_directory::type& directory = tiff_directory::default_value::value
|
||||
)
|
||||
: image_read_settings_base( top_left
|
||||
|
||||
Reference in New Issue
Block a user