Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:58

0001 //
0002 // Copyright 2010 Kenneth Riddile
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
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   // is read_and_no_convert
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 >& /* info */
0047                , std::false_type  // is read_and_convert
0048                )
0049 {
0050     return true;
0051 }
0052 
0053 } // namespace detail
0054 } // namespace gil
0055 } // namespace boost
0056 
0057 #endif