Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //
0002 // Copyright 2009 Christian Henning
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_RAW_DETAIL_IS_ALLOWED_HPP
0009 #define BOOST_GIL_EXTENSION_IO_RAW_DETAIL_IS_ALLOWED_HPP
0010 
0011 #include <boost/gil/extension/io/raw/tags.hpp>
0012 #include <boost/gil/io/base.hpp>
0013 
0014 #include <type_traits>
0015 
0016 namespace boost { namespace gil { namespace detail {
0017 
0018 template< typename View >
0019 bool is_allowed( const image_read_info< raw_tag >& info
0020                , std::true_type   // is read_and_no_convert
0021                )
0022 {
0023     using pixel_t = typename get_pixel_type<View>::type;
0024     using num_channel_t = typename num_channels<pixel_t>::value_type;
0025     using channel_t = typename channel_traits<typename element_type<typename View::value_type>::type>::value_type;
0026 
0027     constexpr num_channel_t dst_samples_per_pixel = num_channels<pixel_t>::value;
0028     constexpr unsigned int dst_bits_per_pixel = detail::unsigned_integral_num_bits<channel_t>::value;
0029     constexpr bool is_type_signed = std::is_signed<channel_t>::value;
0030 
0031     return (dst_samples_per_pixel == info._samples_per_pixel &&
0032             dst_bits_per_pixel == static_cast<unsigned int>(info._bits_per_pixel) &&
0033             !is_type_signed);
0034 }
0035 
0036 template< typename View >
0037 bool is_allowed( const image_read_info< raw_tag >& /* info */
0038                , std::false_type  // is read_and_convert
0039                )
0040 {
0041     return true;
0042 }
0043 
0044 } // namespace detail
0045 } // namespace gil
0046 } // namespace boost
0047 
0048 #endif