File indexing completed on 2025-01-18 09:36:58
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_GIL_EXTENSION_IO_TARGA_DETAIL_IS_ALLOWED_HPP
0009 #define BOOST_GIL_EXTENSION_IO_TARGA_DETAIL_IS_ALLOWED_HPP
0010
0011 #include <boost/gil/extension/io/targa/tags.hpp>
0012
0013 #include <type_traits>
0014
0015 namespace boost { namespace gil { namespace detail {
0016
0017 template< typename View >
0018 bool is_allowed( const image_read_info< targa_tag >& info
0019 , std::true_type
0020 )
0021 {
0022 targa_depth::type src_bits_per_pixel = 0;
0023
0024 switch( info._bits_per_pixel )
0025 {
0026 case 24:
0027 case 32:
0028 {
0029 src_bits_per_pixel = info._bits_per_pixel;
0030 break;
0031 }
0032 default:
0033 {
0034 io_error( "Pixel size not supported." );
0035 break;
0036 }
0037 }
0038
0039 using channel_t = typename channel_traits<typename element_type<typename View::value_type>::type>::value_type;
0040 targa_depth::type dst_bits_per_pixel = detail::unsigned_integral_num_bits< channel_t >::value * num_channels< View >::value;
0041
0042 return ( dst_bits_per_pixel == src_bits_per_pixel );
0043 }
0044
0045 template< typename View >
0046 bool is_allowed( const image_read_info< targa_tag >&
0047 , std::false_type
0048 )
0049 {
0050 return true;
0051 }
0052
0053 }
0054 }
0055 }
0056
0057 #endif