2 // Copyright 2010 Kenneth Riddile
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
8 #ifndef BOOST_GIL_EXTENSION_IO_TARGA_DETAIL_IS_ALLOWED_HPP
9 #define BOOST_GIL_EXTENSION_IO_TARGA_DETAIL_IS_ALLOWED_HPP
11 #include <boost/gil/extension/io/targa/tags.hpp>
13 #include <type_traits>
15 namespace boost { namespace gil { namespace detail {
17 template< typename View >
18 bool is_allowed( const image_read_info< targa_tag >& info
19 , std::true_type // is read_and_no_convert
22 targa_depth::type src_bits_per_pixel = 0;
24 switch( info._bits_per_pixel )
29 src_bits_per_pixel = info._bits_per_pixel;
34 io_error( "Pixel size not supported." );
39 using channel_t = typename channel_traits<typename element_type<typename View::value_type>::type>::value_type;
40 targa_depth::type dst_bits_per_pixel = detail::unsigned_integral_num_bits< channel_t >::value * num_channels< View >::value;
42 return ( dst_bits_per_pixel == src_bits_per_pixel );
45 template< typename View >
46 bool is_allowed( const image_read_info< targa_tag >& /* info */
47 , std::false_type // is read_and_convert