Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / gil / extension / io / targa / detail / supported_types.hpp
1 //
2 // Copyright 2010 Kenneth Riddile
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_TARGA_DETAIL_SUPPORTED_TYPES_HPP
9 #define BOOST_GIL_EXTENSION_IO_TARGA_DETAIL_SUPPORTED_TYPES_HPP
10
11 #include <boost/gil/extension/io/targa/tags.hpp>
12
13 #include <boost/gil/channel.hpp>
14 #include <boost/gil/color_base.hpp>
15 #include <boost/gil/io/base.hpp>
16
17 #include <type_traits>
18
19 namespace boost { namespace gil { namespace detail {
20
21 // Read support
22
23 template< typename Channel
24         , typename ColorSpace
25         >
26 struct targa_read_support : read_support_false
27 {
28     static const targa_depth::type bpp = 0;
29 };
30
31 template<>
32 struct targa_read_support<uint8_t
33                          , rgb_t
34                          > : read_support_true
35 {
36     static const targa_depth::type bpp = 24;
37 };
38
39
40 template<>
41 struct targa_read_support<uint8_t
42                          , rgba_t
43                          > : read_support_true
44 {
45     static const targa_depth::type bpp = 32;
46 };
47
48
49 // Write support
50
51 template< typename Channel
52         , typename ColorSpace
53         >
54 struct targa_write_support : write_support_false
55 {};
56
57 template<>
58 struct targa_write_support<uint8_t
59                           , rgb_t
60                           > : write_support_true {};
61
62 template<>
63 struct targa_write_support<uint8_t
64                           , rgba_t
65                           > : write_support_true {};
66
67 } // namespace detail
68
69 template<typename Pixel>
70 struct is_read_supported<Pixel, targa_tag>
71     : std::integral_constant
72         <
73             bool,
74             detail::targa_read_support
75             <
76                 typename channel_type<Pixel>::type,
77                 typename color_space_type<Pixel>::type
78             >::is_supported
79         >
80 {
81     using parent_t = detail::targa_read_support
82         <
83             typename channel_type<Pixel>::type,
84             typename color_space_type<Pixel>::type
85         >;
86
87     static const typename targa_depth::type bpp = parent_t::bpp;
88 };
89
90 template<typename Pixel>
91 struct is_write_supported<Pixel, targa_tag>
92     : std::integral_constant
93         <
94             bool,
95             detail::targa_write_support
96             <
97                 typename channel_type<Pixel>::type,
98                 typename color_space_type<Pixel>::type
99             >::is_supported
100         >
101 {};
102
103 }} // namespace boost::gil
104
105 #endif