2 // Copyright 2008 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_PNM_DETAIL_SUPPORTED_TYPES_HPP
9 #define BOOST_GIL_EXTENSION_IO_PNM_DETAIL_SUPPORTED_TYPES_HPP
11 #include <boost/gil/extension/io/pnm/tags.hpp>
13 #include <boost/gil/channel.hpp>
14 #include <boost/gil/color_base.hpp>
15 #include <boost/gil/io/base.hpp>
17 #include <type_traits>
19 namespace boost { namespace gil { namespace detail {
23 template< pnm_image_type::type ASCII_Type
24 , pnm_image_type::type Binary_Type
26 struct pnm_rw_support_base
28 static const pnm_image_type::type _asc_type = ASCII_Type;
29 static const pnm_image_type::type _bin_type = Binary_Type;
32 template< typename Channel
35 struct pnm_read_support : read_support_false
36 , pnm_rw_support_base< 0
40 template< typename BitField, bool Mutable >
41 struct pnm_read_support< packed_dynamic_channel_reference< BitField
47 , pnm_rw_support_base< pnm_image_type::mono_asc_t::value
48 , pnm_image_type::mono_bin_t::value
52 struct pnm_read_support<uint8_t
55 , pnm_rw_support_base< pnm_image_type::gray_asc_t::value
56 , pnm_image_type::gray_bin_t::value
61 struct pnm_read_support<uint8_t
64 , pnm_rw_support_base< pnm_image_type::color_asc_t::value
65 , pnm_image_type::color_bin_t::value
70 template< typename Channel
73 struct pnm_write_support : write_support_false
76 template< typename BitField, bool Mutable >
77 struct pnm_write_support< packed_dynamic_channel_reference< BitField
82 > : write_support_true
83 , pnm_rw_support_base< pnm_image_type::mono_asc_t::value
84 , pnm_image_type::mono_bin_t::value
89 struct pnm_write_support<uint8_t
91 > : write_support_true
92 , pnm_rw_support_base< pnm_image_type::gray_asc_t::value
93 , pnm_image_type::gray_bin_t::value
98 struct pnm_write_support<uint8_t
100 > : write_support_true
101 , pnm_rw_support_base< pnm_image_type::color_asc_t::value
102 , pnm_image_type::color_bin_t::value
105 } // namespace detail
107 template<typename Pixel>
108 struct is_read_supported<Pixel, pnm_tag>
109 : std::integral_constant
112 detail::pnm_read_support
114 typename channel_type<Pixel>::type,
115 typename color_space_type<Pixel>::type
119 using parent_t = detail::pnm_read_support
121 typename channel_type<Pixel>::type,
122 typename color_space_type<Pixel>::type
125 static const pnm_image_type::type _asc_type = parent_t::_asc_type;
126 static const pnm_image_type::type _bin_type = parent_t::_bin_type;
129 template<typename Pixel>
130 struct is_write_supported<Pixel, pnm_tag>
131 : std::integral_constant
134 detail::pnm_write_support
136 typename channel_type<Pixel>::type,
137 typename color_space_type<Pixel>::type