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_RAW_DETAIL_IS_ALLOWED_HPP
9 #define BOOST_GIL_EXTENSION_IO_RAW_DETAIL_IS_ALLOWED_HPP
11 #include <boost/gil/extension/io/raw/tags.hpp>
12 #include <boost/gil/io/base.hpp>
14 #include <type_traits>
16 namespace boost { namespace gil { namespace detail {
18 template< typename View >
19 bool is_allowed( const image_read_info< raw_tag >& info
20 , std::true_type // is read_and_no_convert
23 using pixel_t = typename get_pixel_type<View>::type;
24 using num_channel_t = typename num_channels<pixel_t>::value_type;
25 using channel_t = typename channel_traits<typename element_type<typename View::value_type>::type>::value_type;
27 constexpr num_channel_t dst_samples_per_pixel = num_channels<pixel_t>::value;
28 constexpr unsigned int dst_bits_per_pixel = detail::unsigned_integral_num_bits<channel_t>::value;
29 constexpr bool is_type_signed = std::is_signed<channel_t>::value;
31 return (dst_samples_per_pixel == info._samples_per_pixel &&
32 dst_bits_per_pixel == static_cast<unsigned int>(info._bits_per_pixel) &&
36 template< typename View >
37 bool is_allowed( const image_read_info< raw_tag >& /* info */
38 , std::false_type // is read_and_convert