2 // Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
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_TOOLBOX_METAFUNCTIONS_CHANNEL_TYPE_HPP
9 #define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_CHANNEL_TYPE_HPP
11 #include <boost/gil/extension/toolbox/dynamic_images.hpp>
12 #include <boost/gil/extension/toolbox/metafunctions/get_num_bits.hpp>
13 #include <boost/gil/extension/toolbox/metafunctions/is_homogeneous.hpp>
15 #include <boost/gil/bit_aligned_pixel_reference.hpp>
16 #include <boost/gil/channel.hpp>
17 #include <boost/gil/detail/mp11.hpp>
19 #include <boost/utility/enable_if.hpp> // boost::lazy_enable_if
21 namespace boost{ namespace gil {
23 /// channel_type metafunction
24 /// \brief Generates the channel type for
26 template <typename B, typename C, typename L, bool M>
29 using type = packed_dynamic_channel_reference
32 mp11::mp_at_c<C, 0>::value,
37 //! This implementation works for bit_algined_pixel_reference
38 //! with a homogeneous channel layout.
39 //! The result type will be a packed_dynamic_channel_reference, since the
40 //! offset info will be missing.
42 // bit_aligned_pixel_reference
43 template <typename B, typename C, typename L, bool M>
44 struct channel_type< bit_aligned_pixel_reference<B,C,L,M> >
45 : lazy_enable_if< is_homogeneous< bit_aligned_pixel_reference< B, C, L, M > >
46 , gen_chan_ref< B, C, L, M >
49 template <typename B, typename C, typename L, bool M>
50 struct channel_type<const bit_aligned_pixel_reference<B,C,L,M> >
51 : lazy_enable_if< is_homogeneous< bit_aligned_pixel_reference< B, C, L, M > >
52 , gen_chan_ref< B, C, L, M >
55 template <typename B, typename C, typename L>
58 using type = packed_dynamic_channel_reference
61 get_num_bits<mp11::mp_at_c<C, 0>>::value,
67 template < typename BitField
68 , typename ChannelRefs
71 struct channel_type< packed_pixel< BitField
75 > : lazy_enable_if< is_homogeneous< packed_pixel< BitField
80 , gen_chan_ref_p< BitField
86 template <typename B, typename C, typename L>
87 struct channel_type< const packed_pixel< B, C, L > >
88 : lazy_enable_if< is_homogeneous<packed_pixel< B, C, L > >
89 , gen_chan_ref_p< B, C, L >
94 struct channel_type< any_image_pixel_t >
96 using type = any_image_channel_t;