2 // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
3 // Copyright 2005-2007 Adobe Systems Incorporated
5 // Distributed under the Boost Software License, Version 1.0
6 // See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt
9 #include <boost/gil/channel.hpp>
10 #include <boost/gil/color_base_algorithm.hpp>
11 #include <boost/gil/concepts/pixel.hpp>
12 #include <boost/gil/pixel.hpp>
13 #include <boost/gil/planar_pixel_reference.hpp>
14 #include <boost/gil/promote_integral.hpp>
15 #include <boost/gil/typedefs.hpp>
17 #include <boost/core/ignore_unused.hpp>
18 #include <boost/mp11.hpp>
19 #include <boost/mp11/mpl.hpp> // for compatibility with Boost.Test
24 #include <type_traits>
26 namespace boost { namespace gil {
28 namespace test { namespace fixture {
30 template <typename Pixel, int Tag = 0>
38 pixel_value() = default;
39 explicit pixel_value(pixel_t const& pixel)
40 : pixel_(pixel) // test copy constructor
42 type temp_pixel; // test default constructor
43 boost::ignore_unused(temp_pixel);
44 boost::function_requires<PixelValueConcept<pixel_t> >();
48 // Alias compatible with naming of equivalent class in the test/legacy/pixel.cpp
49 // The core suffix indicates `Pixel` is GIL core pixel type.
50 template <typename Pixel, int Tag = 0>
51 using value_core = pixel_value<Pixel, Tag>;
53 template <typename PixelRef, int Tag = 0>
54 struct pixel_reference
57 typename std::remove_reference<PixelRef>::type,
62 std::is_reference<PixelRef>::value ||
63 gil::is_planar<PixelRef>::value, // poor-man test for specialization of planar_pixel_reference
64 "PixelRef must be reference or gil::planar_pixel_reference");
66 using type = PixelRef;
67 using pixel_t = typename std::remove_reference<PixelRef>::type;
68 using parent_t = pixel_value<typename pixel_t::value_type, Tag>;
69 using value_t = typename pixel_t::value_type;
70 type pixel_{}; // reference
72 pixel_reference() : parent_t{}, pixel_(parent_t::pixel_) {}
73 explicit pixel_reference(value_t const& pixel) : parent_t(pixel), pixel_(parent_t::pixel_)
75 boost::function_requires<PixelConcept<pixel_t>>();
79 // Alias compatible with naming of equivalent class in the test/legacy/pixel.cpp
80 // The core suffix indicates `Pixel` is GIL core pixel type.
81 template <typename Pixel, int Tag = 0>
82 using reference_core = pixel_reference<Pixel, Tag>;
84 // Metafunction to yield nested type of a representative pixel type
85 template <typename PixelValueOrReference>
86 using nested_type = typename PixelValueOrReference::type;
88 // Metafunction to yield nested type of a representative pixel_t type
89 template <typename PixelValueOrReference>
90 using nested_pixel_type = typename PixelValueOrReference::pixel_t;
92 // Subset of pixel models that covers all color spaces, channel depths,
93 // reference/value, planar/interleaved, const/mutable.
94 // Operations like color conversion will be invoked on pairs of those.
95 using representative_pixel_types= ::boost::mp11::mp_list
97 value_core<gil::gray8_pixel_t>,
98 reference_core<gil::gray16_pixel_t&>,
99 value_core<gil::bgr8_pixel_t>,
100 reference_core<gil::rgb8_planar_ref_t>,
101 value_core<gil::argb32_pixel_t>,
102 reference_core<gil::cmyk32f_pixel_t&>,
103 reference_core<gil::abgr16c_ref_t>, // immutable reference
104 reference_core<gil::rgb32fc_planar_ref_t>
108 // List of all integer-based core pixel typedefs (i.e. with cv-qualifiers)
109 using pixel_integer_types = ::boost::mp11::mp_list
114 gil::gray16s_pixel_t,
116 gil::gray32s_pixel_t,
132 gil::abgr16s_pixel_t,
134 gil::abgr32s_pixel_t,
138 gil::bgra16s_pixel_t,
140 gil::bgra32s_pixel_t,
144 gil::cmyk16s_pixel_t,
146 gil::cmyk32s_pixel_t,
150 gil::rgba16s_pixel_t,
155 // List of all integer-based core pixel typedefs (i.e. with cv-qualifiers)
156 using pixel_float_types = ::boost::mp11::mp_list
158 gil::gray32f_pixel_t,
161 gil::abgr32f_pixel_t,
162 gil::bgra32f_pixel_t,
163 gil::cmyk32f_pixel_t,
168 // List of all core pixel types (i.e. without cv-qualifiers)
169 using pixel_types = ::boost::mp11::mp_append
175 // List of all core pixel typedefs (i.e. with cv-qualifiers)
176 using pixel_typedefs = ::boost::mp11::mp_append
180 ::boost::mp11::mp_list
183 gil::gray8sc_pixel_t,
184 gil::gray16c_pixel_t,
185 gil::gray16sc_pixel_t,
186 gil::gray32c_pixel_t,
187 gil::gray32fc_pixel_t,
188 gil::gray32sc_pixel_t,
192 gil::bgr16sc_pixel_t,
194 gil::bgr32fc_pixel_t,
195 gil::bgr32sc_pixel_t,
199 gil::rgb16sc_pixel_t,
201 gil::rgb32fc_pixel_t,
202 gil::rgb32sc_pixel_t,
204 gil::abgr8sc_pixel_t,
205 gil::abgr16c_pixel_t,
206 gil::abgr16sc_pixel_t,
207 gil::abgr32c_pixel_t,
208 gil::abgr32fc_pixel_t,
209 gil::abgr32sc_pixel_t,
211 gil::bgra8sc_pixel_t,
212 gil::bgra16c_pixel_t,
213 gil::bgra16sc_pixel_t,
214 gil::bgra32c_pixel_t,
215 gil::bgra32fc_pixel_t,
216 gil::bgra32sc_pixel_t,
218 gil::cmyk8sc_pixel_t,
219 gil::cmyk16c_pixel_t,
220 gil::cmyk16sc_pixel_t,
221 gil::cmyk32c_pixel_t,
222 gil::cmyk32fc_pixel_t,
223 gil::cmyk32sc_pixel_t,
225 gil::rgba8sc_pixel_t,
226 gil::rgba16c_pixel_t,
227 gil::rgba16sc_pixel_t,
228 gil::rgba32c_pixel_t,
229 gil::rgba32fc_pixel_t,
230 gil::rgba32sc_pixel_t
234 struct not_a_pixel_type {};
236 using non_pixels = ::boost::mp11::mp_list
248 }}}} // namespace boost::gil::test::fixture