1 // 2 // Copyright 2008 Christian Henning, Lubomir Bourdev 3 // 4 // Distributed under the Boost Software License, Version 1.0 5 // See accompanying file LICENSE_1_0.txt or copy at 6 // http://www.boost.org/LICENSE_1_0.txt 7 // 8 #ifndef BOOST_GIL_EXTENSION_IO_PNG_DETAIL_IS_ALLOWED_HPP 9 #define BOOST_GIL_EXTENSION_IO_PNG_DETAIL_IS_ALLOWED_HPP 10 11 #include <boost/gil/extension/io/png/tags.hpp> 12 13 #include <type_traits> 14 15 namespace boost { namespace gil { namespace detail { 16 17 template< typename View > is_allowed(const image_read_info<png_tag> & info,std::true_type)18bool is_allowed( const image_read_info< png_tag >& info 19 , std::true_type // is read_and_no_convert 20 ) 21 { 22 using pixel_t = typename get_pixel_type<View>::type; 23 24 using channel_t = typename channel_traits<typename element_type<pixel_t>::type>::value_type; 25 26 const png_num_channels::type dst_num_channels = num_channels< pixel_t >::value; 27 const png_bitdepth::type dst_bit_depth = detail::unsigned_integral_num_bits< channel_t >::value; 28 29 return dst_num_channels == info._num_channels 30 && dst_bit_depth == info._bit_depth; 31 } 32 33 template< typename View > is_allowed(const image_read_info<png_tag> &,std::false_type)34bool is_allowed( const image_read_info< png_tag >& /* info */ 35 , std::false_type // is read_and_convert 36 ) 37 { 38 return true; 39 } 40 41 } // namespace detail 42 } // namespace gil 43 } // namespace boost 44 45 #endif 46