Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / gil / extension / io / jpeg / detail / is_allowed.hpp
1 //
2 // Copyright 2009 Christian Henning
3 //
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
7 //
8 #ifndef BOOST_GIL_EXTENSION_IO_JPEG_DETAIL_IS_ALLOWED_HPP
9 #define BOOST_GIL_EXTENSION_IO_JPEG_DETAIL_IS_ALLOWED_HPP
10
11 #include <boost/gil/extension/io/jpeg/tags.hpp>
12
13 #include <type_traits>
14
15 namespace boost { namespace gil { namespace detail {
16
17 template< typename View >
18 bool is_allowed( const image_read_info< jpeg_tag >& info
19                , std::true_type   // is read_and_no_convert
20                )
21 {
22     if( info._color_space == JCS_YCbCr )
23     {
24         // We read JCS_YCbCr files as rgb.
25         return ( is_read_supported< typename View::value_type
26                                   , jpeg_tag
27                                   >::_color_space == JCS_RGB );
28     }
29
30     return ( is_read_supported< typename View::value_type
31                               , jpeg_tag
32                               >::_color_space == info._color_space );
33 }
34
35 template< typename View >
36 bool is_allowed( const image_read_info< jpeg_tag >& /* info */
37                , std::false_type  // is read_and_convert
38                )
39 {
40     return true;
41 }
42
43 } // namespace detail
44 } // namespace gil
45 } // namespace boost
46
47 #endif