summaryrefslogtreecommitdiff
path: root/boost/gil/extension/io/png
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:22:41 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:22:41 +0900
commit3c1df2168531ad5580076ae08d529054689aeedd (patch)
tree941aff6f86393eecacddfec252a8508c7e8351c9 /boost/gil/extension/io/png
parentd6a306e745acfee00e81ccaf3324a2a03516db41 (diff)
downloadboost-3c1df2168531ad5580076ae08d529054689aeedd.tar.gz
boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.bz2
boost-3c1df2168531ad5580076ae08d529054689aeedd.zip
Imported Upstream version 1.70.0upstream/1.70.0
Diffstat (limited to 'boost/gil/extension/io/png')
-rw-r--r--boost/gil/extension/io/png/detail/base.hpp26
-rw-r--r--boost/gil/extension/io/png/detail/is_allowed.hpp7
-rw-r--r--boost/gil/extension/io/png/detail/read.hpp51
-rw-r--r--boost/gil/extension/io/png/detail/reader_backend.hpp73
-rw-r--r--boost/gil/extension/io/png/detail/scanline_read.hpp10
-rw-r--r--boost/gil/extension/io/png/detail/supported_types.hpp20
-rw-r--r--boost/gil/extension/io/png/detail/write.hpp60
-rw-r--r--boost/gil/extension/io/png/detail/writer_backend.hpp28
8 files changed, 142 insertions, 133 deletions
diff --git a/boost/gil/extension/io/png/detail/base.hpp b/boost/gil/extension/io/png/detail/base.hpp
index 7feb6f8f09..7af4ef1f22 100644
--- a/boost/gil/extension/io/png/detail/base.hpp
+++ b/boost/gil/extension/io/png/detail/base.hpp
@@ -10,6 +10,8 @@
#include <boost/gil/extension/io/png/tags.hpp>
+#include <boost/assert.hpp>
+
#include <memory>
namespace boost { namespace gil { namespace detail {
@@ -17,8 +19,8 @@ namespace boost { namespace gil { namespace detail {
struct png_ptr_wrapper
{
png_ptr_wrapper()
- : _struct( NULL )
- , _info ( NULL )
+ : _struct( nullptr )
+ , _info ( nullptr )
{}
png_structp _struct;
@@ -46,13 +48,13 @@ protected:
{}
png_ptr_wrapper* get() { return _png_ptr.get(); }
- const png_ptr_wrapper* get() const { return _png_ptr.get(); }
+ png_ptr_wrapper const* get() const { return _png_ptr.get(); }
- png_structp get_struct() { return get()->_struct; }
- const png_structp get_struct() const { return get()->_struct; }
+ png_struct* get_struct() { return get()->_struct; }
+ png_struct const* get_struct() const { return get()->_struct; }
- png_infop get_info() { return get()->_info; }
- const png_infop get_info() const { return get()->_info; }
+ png_info* get_info() { return get()->_info; }
+ png_info const* get_info() const { return get()->_info; }
private:
@@ -60,15 +62,15 @@ private:
{
if( png_ptr )
{
- assert( png_ptr->_struct && png_ptr->_info );
+ BOOST_ASSERT(png_ptr->_struct && png_ptr->_info);
png_destroy_read_struct( &png_ptr->_struct
, &png_ptr->_info
- , NULL
+ , nullptr
);
delete png_ptr;
- png_ptr = NULL;
+ png_ptr = nullptr;
}
}
@@ -76,14 +78,14 @@ private:
{
if( png_ptr )
{
- assert( png_ptr->_struct && png_ptr->_info );
+ BOOST_ASSERT(png_ptr->_struct && png_ptr->_info);
png_destroy_write_struct( &png_ptr->_struct
, &png_ptr->_info
);
delete png_ptr;
- png_ptr = NULL;
+ png_ptr = nullptr;
}
}
diff --git a/boost/gil/extension/io/png/detail/is_allowed.hpp b/boost/gil/extension/io/png/detail/is_allowed.hpp
index ac1f9c1749..3fe8386bb6 100644
--- a/boost/gil/extension/io/png/detail/is_allowed.hpp
+++ b/boost/gil/extension/io/png/detail/is_allowed.hpp
@@ -8,6 +8,8 @@
#ifndef BOOST_GIL_EXTENSION_IO_PNG_DETAIL_IS_ALLOWED_HPP
#define BOOST_GIL_EXTENSION_IO_PNG_DETAIL_IS_ALLOWED_HPP
+#include <boost/gil/extension/io/png/tags.hpp>
+
#include <boost/mpl/bool_fwd.hpp>
#include <boost/mpl/for_each.hpp>
@@ -18,10 +20,9 @@ bool is_allowed( const image_read_info< png_tag >& info
, mpl::true_ // is read_and_no_convert
)
{
- typedef typename get_pixel_type< View >::type pixel_t;
+ using pixel_t = typename get_pixel_type<View>::type;
- typedef typename channel_traits<
- typename element_type< pixel_t >::type >::value_type channel_t;
+ using channel_t = typename channel_traits<typename element_type<pixel_t>::type>::value_type;
const png_num_channels::type dst_num_channels = num_channels< pixel_t >::value;
const png_bitdepth::type dst_bit_depth = detail::unsigned_integral_num_bits< channel_t >::value;
diff --git a/boost/gil/extension/io/png/detail/read.hpp b/boost/gil/extension/io/png/detail/read.hpp
index f14e32a1cf..148f023fb1 100644
--- a/boost/gil/extension/io/png/detail/read.hpp
+++ b/boost/gil/extension/io/png/detail/read.hpp
@@ -16,6 +16,7 @@
#include <boost/gil/io/base.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>
#include <boost/gil/io/typedefs.hpp>
@@ -45,16 +46,12 @@ class reader< Device
{
private:
- typedef reader< Device
- , png_tag
- , ConversionPolicy
- > this_t;
-
- typedef typename ConversionPolicy::color_converter_type cc_t;
+ using this_t = reader<Device, png_tag, ConversionPolicy>;
+ using cc_t = typename ConversionPolicy::color_converter_type;
public:
- typedef reader_backend< Device, png_tag > backend_t;
+ using backend_t = reader_backend<Device, png_tag>;
public:
@@ -220,7 +217,7 @@ public:
// read rest of file, and get additional chunks in info_ptr
png_read_end( this->get_struct()
- , NULL
+ , nullptr
);
}
@@ -231,13 +228,15 @@ private:
>
void read_rows( const View& view )
{
- typedef detail::row_buffer_helper_view< ImagePixel > row_buffer_helper_t;
+ using row_buffer_helper_t = detail::row_buffer_helper_view<ImagePixel>;
- typedef typename row_buffer_helper_t::iterator_t it_t;
+ using it_t = typename row_buffer_helper_t::iterator_t;
- typedef typename is_same< ConversionPolicy
- , detail::read_and_no_convert
- >::type is_read_and_convert_t;
+ using is_read_and_convert_t = typename is_same
+ <
+ ConversionPolicy,
+ detail::read_and_no_convert
+ >::type;
io_error_if( !detail::is_allowed< View >( this->_info
, is_read_and_convert_t()
@@ -265,7 +264,7 @@ private:
// Read the image using the "sparkle" effect.
png_read_rows( this->get_struct()
, &row_ptr
- , NULL
+ , nullptr
, 1
);
}
@@ -278,7 +277,7 @@ private:
// Read the image using the "sparkle" effect.
png_read_rows( this->get_struct()
, &row_ptr
- , NULL
+ , nullptr
, 1
);
@@ -302,7 +301,7 @@ private:
// Read the image using the "sparkle" effect.
png_read_rows( this->get_struct()
, &row_ptr
- , NULL
+ , nullptr
, 1
);
}
@@ -314,7 +313,7 @@ private:
// Read the image using the "sparkle" effect.
png_read_rows( this->get_struct()
, &row_ptr
- , NULL
+ , nullptr
, 1
);
}
@@ -337,9 +336,11 @@ struct png_type_format_checker
template< typename Image >
bool apply()
{
- typedef is_read_supported< typename get_pixel_type< typename Image::view_t >::type
- , png_tag
- > is_supported_t;
+ using is_supported_t = is_read_supported
+ <
+ typename get_pixel_type<typename Image::view_t>::type,
+ png_tag
+ >;
return is_supported_t::_bit_depth == _bit_depth
&& is_supported_t::_color_type == _color_type;
@@ -376,10 +377,12 @@ class dynamic_image_reader< Device
, detail::read_and_no_convert
>
{
- typedef reader< Device
- , png_tag
- , detail::read_and_no_convert
- > parent_t;
+ using parent_t = reader
+ <
+ Device,
+ png_tag,
+ detail::read_and_no_convert
+ >;
public:
diff --git a/boost/gil/extension/io/png/detail/reader_backend.hpp b/boost/gil/extension/io/png/detail/reader_backend.hpp
index 18085b8746..aaf5843ef0 100644
--- a/boost/gil/extension/io/png/detail/reader_backend.hpp
+++ b/boost/gil/extension/io/png/detail/reader_backend.hpp
@@ -31,14 +31,8 @@ struct reader_backend< Device
{
public:
- typedef png_tag format_tag_t;
-
-public:
-
- typedef reader_backend< Device
- , png_tag
- > this_t;
-
+ using format_tag_t = png_tag;
+ using this_t = reader_backend<Device, png_tag>;
public:
@@ -92,12 +86,12 @@ public:
// the compiler header file version, so that we know if the application
// was compiled with a compatible version of the library. REQUIRED
get()->_struct = png_create_read_struct( PNG_LIBPNG_VER_STRING
- , NULL // user_error_ptr
- , NULL // user_error_fn
- , NULL // user_warning_fn
+ , nullptr // user_error_ptr
+ , nullptr // user_error_fn
+ , nullptr // user_warning_fn
);
- io_error_if( get()->_struct == NULL
+ io_error_if( get()->_struct == nullptr
, "png_reader: fail to call png_create_write_struct()"
);
@@ -114,11 +108,11 @@ public:
// Allocate/initialize the memory for image information. REQUIRED.
get()->_info = png_create_info_struct( get_struct() );
- if( get_info() == NULL )
+ if( get_info() == nullptr )
{
png_destroy_read_struct( &get()->_struct
- , NULL
- , NULL
+ , nullptr
+ , nullptr
);
io_error( "png_reader: fail to call png_create_info_struct()" );
@@ -132,7 +126,7 @@ public:
//free all of the memory associated with the png_ptr and info_ptr
png_destroy_read_struct( &get()->_struct
, &get()->_info
- , NULL
+ , nullptr
);
io_error( "png is invalid" );
@@ -153,12 +147,12 @@ public:
// Set up a callback which implements user defined transformation.
// @todo
png_set_read_user_transform_fn( get_struct()
- , png_user_transform_ptr( NULL )
+ , png_user_transform_ptr( nullptr )
);
png_set_keep_unknown_chunks( get_struct()
, PNG_HANDLE_CHUNK_ALWAYS
- , NULL
+ , nullptr
, 0
);
@@ -256,8 +250,8 @@ public:
if( this->_settings._read_icc_profile )
{
#if PNG_LIBPNG_VER_MINOR >= 5
- png_charp icc_name = png_charp( NULL );
- png_bytep profile = png_bytep( NULL );
+ png_charp icc_name = png_charp( nullptr );
+ png_bytep profile = png_bytep( nullptr );
this->_info._valid_icc_profile = png_get_iCCP( get_struct()
, get_info()
@@ -303,7 +297,7 @@ public:
// get image palette information from png_info structure
if( this->_settings._read_palette )
{
- png_colorp palette = png_colorp( NULL );
+ png_colorp palette = png_colorp( nullptr );
this->_info._valid_palette = png_get_PLTE( get_struct()
, get_info()
@@ -324,7 +318,7 @@ public:
// get background color
if( this->_settings._read_background )
{
- png_color_16p background = png_color_16p( NULL );
+ png_color_16p background = png_color_16p( nullptr );
this->_info._valid_background = png_get_bKGD( get_struct()
, get_info()
@@ -339,7 +333,7 @@ public:
// get the histogram
if( this->_settings._read_histogram )
{
- png_uint_16p histogram = png_uint_16p( NULL );
+ png_uint_16p histogram = png_uint_16p( nullptr );
this->_info._valid_histogram = png_get_hIST( get_struct()
, get_info()
@@ -352,7 +346,7 @@ public:
// the palette.
if( this->_settings._read_palette == false )
{
- png_colorp palette = png_colorp( NULL );
+ png_colorp palette = png_colorp( nullptr );
png_get_PLTE( get_struct()
, get_info()
, &palette
@@ -382,9 +376,9 @@ public:
// get pixel calibration settings
if( this->_settings._read_pixel_calibration )
{
- png_charp purpose = png_charp ( NULL );
- png_charp units = png_charp ( NULL );
- png_charpp params = png_charpp( NULL );
+ png_charp purpose = png_charp ( nullptr );
+ png_charp units = png_charp ( nullptr );
+ png_charpp params = png_charpp( nullptr );
this->_info._valid_pixel_calibration = png_get_pCAL( get_struct()
, get_info()
@@ -449,7 +443,7 @@ public:
// get number of significant bits for each color channel
if( this->_settings._read_number_of_significant_bits )
{
- png_color_8p sig_bits = png_color_8p( NULL );
+ png_color_8p sig_bits = png_color_8p( nullptr );
this->_info._valid_significant_bits = png_get_sBIT( get_struct()
, get_info()
@@ -491,16 +485,13 @@ public:
#else
if( this->_settings._read_scale_factors )
{
- png_charp scale_width = NULL;
- png_charp scale_height = NULL;
+ png_charp scale_width = nullptr;
+ png_charp scale_height = nullptr;
- if( this->_info._valid_scale_factors = png_get_sCAL_s( get_struct()
- , get_info()
- , &this->_info._scale_unit
- , &scale_width
- , &scale_height
- ) > 0
- )
+ this->_info._valid_scale_factors = png_get_sCAL_s(
+ get_struct(), get_info(), &this->_info._scale_unit, &scale_width, &scale_height);
+
+ if (this->_info._valid_scale_factors)
{
if( scale_width )
{
@@ -524,7 +515,7 @@ public:
// get comments information from png_info structure
if( this->_settings._read_comments )
{
- png_textp text = png_textp( NULL );
+ png_textp text = png_textp( nullptr );
this->_info._valid_text = png_get_text( get_struct()
, get_info()
@@ -556,7 +547,7 @@ public:
// get last modification time
if( this->_settings._read_last_modification_time )
{
- png_timep mod_time = png_timep( NULL );
+ png_timep mod_time = png_timep( nullptr );
this->_info._valid_modification_time = png_get_tIME( get_struct()
, get_info()
, &mod_time
@@ -570,8 +561,8 @@ public:
// get transparency data
if( this->_settings._read_transparency_data )
{
- png_bytep trans = png_bytep ( NULL );
- png_color_16p trans_values = png_color_16p( NULL );
+ png_bytep trans = png_bytep ( nullptr );
+ png_color_16p trans_values = png_color_16p( nullptr );
this->_info._valid_transparency_factors = png_get_tRNS( get_struct()
, get_info()
diff --git a/boost/gil/extension/io/png/detail/scanline_read.hpp b/boost/gil/extension/io/png/detail/scanline_read.hpp
index 99374f164a..bb27f85378 100644
--- a/boost/gil/extension/io/png/detail/scanline_read.hpp
+++ b/boost/gil/extension/io/png/detail/scanline_read.hpp
@@ -35,12 +35,10 @@ class scanline_reader< Device
{
public:
- typedef png_tag tag_t;
- typedef reader_backend < Device, tag_t > backend_t;
- typedef scanline_reader< Device, tag_t > this_t;
- typedef scanline_read_iterator< this_t > iterator_t;
-
-public:
+ using tag_t = png_tag;
+ using backend_t = reader_backend<Device, tag_t>;
+ using this_t = scanline_reader<Device, tag_t>;
+ using iterator_t = scanline_read_iterator<this_t>;
//
// Constructor
diff --git a/boost/gil/extension/io/png/detail/supported_types.hpp b/boost/gil/extension/io/png/detail/supported_types.hpp
index ed98917ffc..777d9729a9 100644
--- a/boost/gil/extension/io/png/detail/supported_types.hpp
+++ b/boost/gil/extension/io/png/detail/supported_types.hpp
@@ -8,10 +8,14 @@
#ifndef BOOST_GIL_EXTENSION_IO_PNG_DETAIL_SUPPORTED_TYPES_HPP
#define BOOST_GIL_EXTENSION_IO_PNG_DETAIL_SUPPORTED_TYPES_HPP
+#include <boost/gil/extension/io/png/tags.hpp>
+
#ifdef BOOST_GIL_IO_ENABLE_GRAY_ALPHA
#include <boost/gil/extension/toolbox/color_spaces/gray_alpha.hpp>
#endif // BOOST_GIL_IO_ENABLE_GRAY_ALPHA
+#include <cstddef>
+
namespace boost { namespace gil { namespace detail {
static const size_t PNG_BYTES_TO_CHECK = 4;
@@ -323,9 +327,11 @@ struct is_read_supported< Pixel
>::is_supported
>
{
- typedef detail::png_read_support< typename channel_type< Pixel >::type
- , typename color_space_type< Pixel >::type
- > parent_t;
+ using parent_t = detail::png_read_support
+ <
+ typename channel_type<Pixel>::type,
+ typename color_space_type<Pixel>::type
+ >;
static const png_bitdepth::type _bit_depth = parent_t::_bit_depth;
static const png_color_type::type _color_type = parent_t::_color_type;
@@ -340,9 +346,11 @@ struct is_write_supported< Pixel
>::is_supported
>
{
- typedef detail::png_write_support< typename channel_type< Pixel >::type
- , typename color_space_type< Pixel >::type
- > parent_t;
+ using parent_t = detail::png_write_support
+ <
+ typename channel_type<Pixel>::type,
+ typename color_space_type<Pixel>::type
+ >;
static const png_bitdepth::type _bit_depth = parent_t::_bit_depth;
static const png_color_type::type _color_type = parent_t::_color_type;
diff --git a/boost/gil/extension/io/png/detail/write.hpp b/boost/gil/extension/io/png/detail/write.hpp
index cf1ef2a2a7..9cec03ada5 100644
--- a/boost/gil/extension/io/png/detail/write.hpp
+++ b/boost/gil/extension/io/png/detail/write.hpp
@@ -11,6 +11,7 @@
#include <boost/gil/extension/io/png/detail/writer_backend.hpp>
#include <boost/gil/io/device.hpp>
+#include <boost/gil/io/dynamic_io_new.hpp>
#include <boost/gil/io/row_buffer_helper.hpp>
#include <boost/mpl/and.hpp>
@@ -18,6 +19,8 @@
#include <boost/mpl/less.hpp>
#include <boost/mpl/not.hpp>
+#include <type_traits>
+
namespace boost { namespace gil {
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
@@ -53,7 +56,7 @@ class writer< Device
public:
- typedef writer_backend< Device , png_tag > backend_t;
+ using backend_t = writer_backend<Device, png_tag>;
writer( const Device& io_dev
, const image_write_info< png_tag >& info
@@ -85,11 +88,13 @@ private:
, mpl::false_ // is bit aligned
)
{
- typedef typename get_pixel_type< View >::type pixel_t;
+ using pixel_t = typename get_pixel_type<View>::type;
- typedef detail::png_write_support< typename channel_type < pixel_t >::type
- , typename color_space_type< pixel_t >::type
- > png_rw_info;
+ using png_rw_info = detail::png_write_support
+ <
+ typename channel_type<pixel_t>::type,
+ typename color_space_type<pixel_t>::type
+ >;
if( little_endian() )
{
@@ -123,11 +128,11 @@ private:
, mpl::true_ // is bit aligned
)
{
- typedef detail::png_write_support< typename kth_semantic_element_type< typename View::value_type
- , 0
- >::type
- , typename color_space_type<View>::type
- > png_rw_info;
+ using png_rw_info = detail::png_write_support
+ <
+ typename kth_semantic_element_type<typename View::value_type, 0>::type,
+ typename color_space_type<View>::type
+ >;
if (little_endian() )
{
@@ -164,25 +169,30 @@ private:
template< typename Info > struct is_less_than_eight : mpl::less< mpl::int_< Info::_bit_depth >, mpl::int_< 8 > > {};
template< typename Info > struct is_equal_to_sixteen : mpl::equal_to< mpl::int_< Info::_bit_depth >, mpl::int_< 16 > > {};
- template< typename Info >
- void set_swap( typename enable_if< is_less_than_eight< Info > >::type* /* ptr */ = 0 )
+ template <typename Info>
+ void set_swap(typename std::enable_if<is_less_than_eight<Info>::value>::type* /*ptr*/ = 0)
{
- png_set_packswap( this->get_struct() );
+ png_set_packswap(this->get_struct());
}
- template< typename Info >
- void set_swap( typename enable_if< is_equal_to_sixteen< Info > >::type* /* ptr */ = 0 )
+ template <typename Info>
+ void set_swap(typename std::enable_if<is_equal_to_sixteen<Info>::value>::type* /*ptr*/ = 0)
{
- png_set_swap( this->get_struct() );
+ png_set_swap(this->get_struct());
}
- template< typename Info >
- void set_swap( typename enable_if< mpl::and_< mpl::not_< is_less_than_eight< Info > >
- , mpl::not_< is_equal_to_sixteen< Info > >
- >
- >::type* /* ptr */ = 0
- )
- {}
+ template <typename Info>
+ void set_swap(
+ typename std::enable_if
+ <
+ mpl::and_
+ <
+ mpl::not_<is_less_than_eight<Info>>,
+ mpl::not_<is_equal_to_sixteen<Info>>
+ >::value
+ >::type* /*ptr*/ = nullptr)
+ {
+ }
};
///
@@ -196,9 +206,7 @@ class dynamic_image_writer< Device
, png_tag
>
{
- typedef writer< Device
- , png_tag
- > parent_t;
+ using parent_t = writer<Device, png_tag>;
public:
diff --git a/boost/gil/extension/io/png/detail/writer_backend.hpp b/boost/gil/extension/io/png/detail/writer_backend.hpp
index 659be4fa36..dc9068e4dc 100644
--- a/boost/gil/extension/io/png/detail/writer_backend.hpp
+++ b/boost/gil/extension/io/png/detail/writer_backend.hpp
@@ -35,15 +35,11 @@ struct writer_backend< Device
private:
- typedef writer_backend< Device
- , png_tag
- > this_t;
+ using this_t = writer_backend<Device, png_tag>;
public:
- typedef png_tag format_tag_t;
-
-public:
+ using format_tag_t = png_tag;
///
/// Constructor
@@ -61,22 +57,22 @@ public:
// the library version is compatible with the one used at compile time,
// in case we are using dynamically linked libraries. REQUIRED.
get()->_struct = png_create_write_struct( PNG_LIBPNG_VER_STRING
- , NULL // user_error_ptr
- , NULL // user_error_fn
- , NULL // user_warning_fn
+ , nullptr // user_error_ptr
+ , nullptr // user_error_fn
+ , nullptr // user_warning_fn
);
- io_error_if( get_struct() == NULL
+ io_error_if( get_struct() == nullptr
, "png_writer: fail to call png_create_write_struct()"
);
// Allocate/initialize the image information data. REQUIRED
get()->_info = png_create_info_struct( get_struct() );
- if( get_info() == NULL )
+ if( get_info() == nullptr )
{
png_destroy_write_struct( &get()->_struct
- , NULL
+ , nullptr
);
io_error( "png_writer: fail to call png_create_info_struct()" );
@@ -102,9 +98,11 @@ protected:
template< typename View >
void write_header( const View& view )
{
- typedef detail::png_write_support< typename channel_type< typename get_pixel_type< View >::type >::type
- , typename color_space_type< View >::type
- > png_rw_info_t;
+ using png_rw_info_t = detail::png_write_support
+ <
+ typename channel_type<typename get_pixel_type<View>::type>::type,
+ typename color_space_type<View>::type
+ >;
// Set the image information here. Width and height are up to 2^31,
// bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on