Boost GIL


typedefs.hpp
1 //
2 // Copyright 2005-2007 Adobe Systems Incorporated
3 // Copyright 2018 Mateusz Loskot <mateusz@loskot.net>
4 //
5 // Use, modification and distribution are subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 #ifndef BOOST_GIL_TYPEDEFS_HPP
10 #define BOOST_GIL_TYPEDEFS_HPP
11 
12 #include <boost/gil/cmyk.hpp>
13 #include <boost/gil/device_n.hpp>
14 #include <boost/gil/gray.hpp>
15 #include <boost/gil/point.hpp>
16 #include <boost/gil/rgb.hpp>
17 #include <boost/gil/rgba.hpp>
18 
19 #include <cstdint>
20 #include <memory>
21 #if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
22 # include <memory_resource>
23 #endif
24 
25 // B - bits size/signedness, CM - channel model, CS - colour space, LAYOUT - pixel layout
26 // Example: B = '8', CM = 'uint8_t', CS = 'bgr, LAYOUT='bgr_layout_t'
27 #define BOOST_GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(B, CM, CS, LAYOUT) \
28  template <typename, typename> \
29  struct pixel; \
30  template <typename, typename> \
31  struct planar_pixel_reference; \
32  template <typename, typename> \
33  struct planar_pixel_iterator; \
34  template <typename> \
35  class memory_based_step_iterator; \
36  template <typename> \
37  class point; \
38  template <typename> \
39  class memory_based_2d_locator; \
40  template <typename> \
41  class image_view; \
42  template <typename, bool, typename> \
43  class image; \
44  using CS##B##_pixel_t = pixel<CM, LAYOUT>; \
45  using CS##B##c_pixel_t = pixel<CM, LAYOUT> const; \
46  using CS##B##_ref_t = pixel<CM, LAYOUT>&; \
47  using CS##B##c_ref_t = pixel<CM, LAYOUT> const&; \
48  using CS##B##_ptr_t = CS##B##_pixel_t*; \
49  using CS##B##c_ptr_t = CS##B##c_pixel_t*; \
50  using CS##B##_step_ptr_t = memory_based_step_iterator<CS##B##_ptr_t>; \
51  using CS##B##c_step_ptr_t = memory_based_step_iterator<CS##B##c_ptr_t>; \
52  using CS##B##_loc_t = memory_based_2d_locator<memory_based_step_iterator<CS##B##_ptr_t>>; \
53  using CS##B##c_loc_t = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_ptr_t>>; \
54  using CS##B##_step_loc_t \
55  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_step_ptr_t>>; \
56  using CS##B##c_step_loc_t \
57  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_step_ptr_t>>; \
58  using CS##B##_view_t = image_view<CS##B##_loc_t>; \
59  using CS##B##c_view_t = image_view<CS##B##c_loc_t>; \
60  using CS##B##_step_view_t = image_view<CS##B##_step_loc_t>; \
61  using CS##B##c_step_view_t = image_view<CS##B##c_step_loc_t>; \
62  using CS##B##_image_t = image<CS##B##_pixel_t, false, std::allocator<unsigned char>>;
63 
64 #define BOOST_GIL_DEFINE_BASE_PMR_TYPEDEFS_INTERNAL(B, CM, CS, LAYOUT) \
65  namespace pmr { \
66  using CS##B##_image_t \
67  = image<CS##B##_pixel_t, false, std::pmr::polymorphic_allocator<unsigned char>>; \
68  }
69 
70 // Example: B = '8', CM = 'uint8_t', CS = 'bgr' CS_FULL = 'rgb_t' LAYOUT='bgr_layout_t'
71 #define BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(B, CM, CS, CS_FULL, LAYOUT) \
72  BOOST_GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(B, CM, CS, LAYOUT) \
73  using CS##B##_planar_ref_t = planar_pixel_reference<CM&, CS_FULL>; \
74  using CS##B##c_planar_ref_t = planar_pixel_reference<CM const&, CS_FULL>; \
75  using CS##B##_planar_ptr_t = planar_pixel_iterator<CM*, CS_FULL>; \
76  using CS##B##c_planar_ptr_t = planar_pixel_iterator<CM const*, CS_FULL>; \
77  using CS##B##_planar_step_ptr_t = memory_based_step_iterator<CS##B##_planar_ptr_t>; \
78  using CS##B##c_planar_step_ptr_t = memory_based_step_iterator<CS##B##c_planar_ptr_t>; \
79  using CS##B##_planar_loc_t \
80  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_planar_ptr_t>>; \
81  using CS##B##c_planar_loc_t \
82  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_planar_ptr_t>>; \
83  using CS##B##_planar_step_loc_t \
84  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_planar_step_ptr_t>>; \
85  using CS##B##c_planar_step_loc_t \
86  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_planar_step_ptr_t>>; \
87  using CS##B##_planar_view_t = image_view<CS##B##_planar_loc_t>; \
88  using CS##B##c_planar_view_t = image_view<CS##B##c_planar_loc_t>; \
89  using CS##B##_planar_step_view_t = image_view<CS##B##_planar_step_loc_t>; \
90  using CS##B##c_planar_step_view_t = image_view<CS##B##c_planar_step_loc_t>; \
91  using CS##B##_planar_image_t = image<CS##B##_pixel_t, true, std::allocator<unsigned char>>;
92 
93 #define BOOST_GIL_DEFINE_ALL_PMR_TYPEDEFS_INTERNAL(B, CM, CS, CS_FULL, LAYOUT) \
94  BOOST_GIL_DEFINE_BASE_PMR_TYPEDEFS_INTERNAL(B, CM, CS, LAYOUT) \
95  namespace pmr { \
96  using CS##B##_planar_image_t \
97  = image<CS##B##_pixel_t, true, std::pmr::polymorphic_allocator<unsigned char>>; \
98  }
99 
100 #if defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
101 # define BOOST_GIL_DEFINE_BASE_TYPEDEFS(B, CM, CS) \
102  BOOST_GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(B, CM, CS, CS##_layout_t)
103 
104 # define BOOST_GIL_DEFINE_ALL_TYPEDEFS(B, CM, CS) \
105  BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(B, CM, CS, CS##_t, CS##_layout_t)
106 #else
107 # define BOOST_GIL_DEFINE_BASE_TYPEDEFS(B, CM, CS) \
108  BOOST_GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(B, CM, CS, CS##_layout_t) \
109  BOOST_GIL_DEFINE_BASE_PMR_TYPEDEFS_INTERNAL(B, CM, CS, CS##_layout_t)
110 
111 # define BOOST_GIL_DEFINE_ALL_TYPEDEFS(B, CM, CS) \
112  BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(B, CM, CS, CS##_t, CS##_layout_t) \
113  BOOST_GIL_DEFINE_ALL_PMR_TYPEDEFS_INTERNAL(B, CM, CS, CS##_t, CS##_layout_t)
114 #endif
115 
116 namespace boost { namespace gil {
117 
118 // forward declarations
119 template <typename B, typename Mn, typename Mx> struct scoped_channel_value;
120 template <typename T> struct float_point_zero;
121 template <typename T> struct float_point_one;
122 
126 
129 using std::uint8_t;
130 
133 using std::uint16_t;
134 
137 using std::uint32_t;
138 
141 using std::int8_t;
142 
145 using std::int16_t;
146 
149 using std::int32_t;
150 
153 using float32_t = scoped_channel_value<float, float_point_zero<float>, float_point_one<float>>;
154 
157 using float64_t = scoped_channel_value<double, float_point_zero<double>, float_point_one<double>>;
158 
159 BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, gray)
160 BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, gray)
161 BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, gray)
162 BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, gray)
163 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, gray)
164 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, gray)
165 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, gray)
166 
167 BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, bgr)
168 BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, bgr)
169 BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, bgr)
170 BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, bgr)
171 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, bgr)
172 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, bgr)
173 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, bgr)
174 
175 BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, argb)
176 BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, argb)
177 BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, argb)
178 BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, argb)
179 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, argb)
180 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, argb)
181 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, argb)
182 
183 BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, abgr)
184 BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, abgr)
185 BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, abgr)
186 BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, abgr)
187 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, abgr)
188 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, abgr)
189 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, abgr)
190 
191 BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, bgra)
192 BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, bgra)
193 BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, bgra)
194 BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, bgra)
195 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, bgra)
196 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, bgra)
197 BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, bgra)
198 
199 BOOST_GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, rgb)
200 BOOST_GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, rgb)
201 BOOST_GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, rgb)
202 BOOST_GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, rgb)
203 BOOST_GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, rgb)
204 BOOST_GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, rgb)
205 BOOST_GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, rgb)
206 
207 BOOST_GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, rgba)
208 BOOST_GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, rgba)
209 BOOST_GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, rgba)
210 BOOST_GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, rgba)
211 BOOST_GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, rgba)
212 BOOST_GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, rgba)
213 BOOST_GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, rgba)
214 
215 BOOST_GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, cmyk)
216 BOOST_GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, cmyk)
217 BOOST_GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, cmyk)
218 BOOST_GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, cmyk)
219 BOOST_GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, cmyk)
220 BOOST_GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, cmyk)
221 BOOST_GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, cmyk)
222 
223 template <int N> struct devicen_t;
224 template <int N> struct devicen_layout_t;
225 
226 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
227 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
228 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
229 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
230 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
231 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
232 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
233 
234 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
235 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
236 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
237 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
238 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
239 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
240 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
241 
242 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
243 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
244 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
245 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
246 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
247 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
248 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
249 
250 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
251 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
252 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
253 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
254 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
255 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
256 BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
257 
258 }} // namespace boost::gil
259 
260 #endif
scoped_channel_value< double, float_point_zero< double >, float_point_one< double > > float64_t
64-bit floating point channel type with range [0.0f ... 1.0f]. Models ChannelValueConcept
Definition: typedefs.hpp:157
scoped_channel_value< float, float_point_zero< float >, float_point_one< float > > float32_t
32-bit floating point channel type with range [0.0f ... 1.0f]. Models ChannelValueConcept
Definition: typedefs.hpp:153
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36
unnamed color layout of up to five channels
Definition: device_n.hpp:56
Unnamed color space of 1, 2, 3, 4, or 5 channels.
Definition: device_n.hpp:40