2 // Copyright 2009 Christian Henning
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_BMP_DETAIL_IS_ALLOWED_HPP
9 #define BOOST_GIL_EXTENSION_IO_BMP_DETAIL_IS_ALLOWED_HPP
11 #include <boost/gil/extension/io/bmp/tags.hpp>
12 #include <boost/gil/channel.hpp>
14 #include <type_traits>
16 namespace boost { namespace gil { namespace detail {
18 template< typename View >
19 bool is_allowed( const image_read_info< bmp_tag >& info
20 , std::true_type // is read_and_no_convert
23 bmp_bits_per_pixel::type src_bits_per_pixel = 0;
25 switch( info._bits_per_pixel )
31 if( info._header_size == bmp_header_size::_win32_info_size
32 && info._compression != bmp_compression::_rle8
33 && info._compression != bmp_compression::_rle4
36 src_bits_per_pixel = 32;
40 src_bits_per_pixel = 24;
49 src_bits_per_pixel = 24;
57 src_bits_per_pixel = info._bits_per_pixel;
63 io_error( "Pixel size not supported." );
67 using channel_t = typename channel_traits<typename element_type<typename View::value_type>::type>::value_type;
68 bmp_bits_per_pixel::type dst_bits_per_pixel = detail::unsigned_integral_num_bits< channel_t >::value
69 * num_channels< View >::value;
71 return ( dst_bits_per_pixel == src_bits_per_pixel );
74 template< typename View >
75 bool is_allowed( const image_read_info< bmp_tag >& /* info */
76 , std::false_type // is read_and_convert