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 
22 // B - bits size/signedness, CM - channel model, CS - colour space, LAYOUT - pixel layout
23 // Example: B = '8', CM = 'uint8_t', CS = 'bgr, LAYOUT='bgr_layout_t'
24 #define GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(B, CM, CS, LAYOUT) \
25  template <typename, typename> struct pixel; \
26  template <typename, typename> struct planar_pixel_reference; \
27  template <typename, typename> struct planar_pixel_iterator; \
28  template <typename> class memory_based_step_iterator; \
29  template <typename> class point; \
30  template <typename> class memory_based_2d_locator; \
31  template <typename> class image_view; \
32  template <typename, bool, typename> class image; \
33  using CS##B##_pixel_t = pixel<CM, LAYOUT>; \
34  using CS##B##c_pixel_t = pixel<CM, LAYOUT> const; \
35  using CS##B##_ref_t = pixel<CM, LAYOUT>&; \
36  using CS##B##c_ref_t = pixel<CM, LAYOUT> const&; \
37  using CS##B##_ptr_t = CS##B##_pixel_t*; \
38  using CS##B##c_ptr_t = CS##B##c_pixel_t*; \
39  using CS##B##_step_ptr_t = memory_based_step_iterator<CS##B##_ptr_t>; \
40  using CS##B##c_step_ptr_t = memory_based_step_iterator<CS##B##c_ptr_t>; \
41  using CS##B##_loc_t \
42  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_ptr_t>>; \
43  using CS##B##c_loc_t \
44  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_ptr_t>>; \
45  using CS##B##_step_loc_t \
46  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_step_ptr_t>>; \
47  using CS##B##c_step_loc_t \
48  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_step_ptr_t>>; \
49  using CS##B##_view_t = image_view<CS##B##_loc_t>; \
50  using CS##B##c_view_t = image_view<CS##B##c_loc_t>; \
51  using CS##B##_step_view_t = image_view<CS##B##_step_loc_t>; \
52  using CS##B##c_step_view_t = image_view<CS##B##c_step_loc_t>; \
53  using CS##B##_image_t = image<CS##B##_pixel_t, false, std::allocator<unsigned char>>;
54 
55 // Example: B = '8', CM = 'uint8_t', CS = 'bgr' CS_FULL = 'rgb_t' LAYOUT='bgr_layout_t'
56 #define GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(B, CM, CS, CS_FULL, LAYOUT) \
57  GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(B, CM, CS, LAYOUT) \
58  using CS##B##_planar_ref_t = planar_pixel_reference<CM&, CS_FULL>; \
59  using CS##B##c_planar_ref_t = planar_pixel_reference<CM const&, CS_FULL>; \
60  using CS##B##_planar_ptr_t = planar_pixel_iterator<CM*, CS_FULL>; \
61  using CS##B##c_planar_ptr_t = planar_pixel_iterator<CM const*, CS_FULL>; \
62  using CS##B##_planar_step_ptr_t = memory_based_step_iterator<CS##B##_planar_ptr_t>; \
63  using CS##B##c_planar_step_ptr_t \
64  = memory_based_step_iterator<CS##B##c_planar_ptr_t>; \
65  using CS##B##_planar_loc_t \
66  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_planar_ptr_t>>; \
67  using CS##B##c_planar_loc_t \
68  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_planar_ptr_t>>; \
69  using CS##B##_planar_step_loc_t \
70  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_planar_step_ptr_t>>; \
71  using CS##B##c_planar_step_loc_t \
72  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_planar_step_ptr_t>>; \
73  using CS##B##_planar_view_t = image_view<CS##B##_planar_loc_t>; \
74  using CS##B##c_planar_view_t = image_view<CS##B##c_planar_loc_t>; \
75  using CS##B##_planar_step_view_t = image_view<CS##B##_planar_step_loc_t>; \
76  using CS##B##c_planar_step_view_t = image_view<CS##B##c_planar_step_loc_t>; \
77  using CS##B##_planar_image_t \
78  = image<CS##B##_pixel_t, true, std::allocator<unsigned char>>;
79 
80 #define GIL_DEFINE_BASE_TYPEDEFS(B, CM, CS) \
81  GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(B, CM, CS, CS##_layout_t)
82 
83 #define GIL_DEFINE_ALL_TYPEDEFS(B, CM, CS) \
84  GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(B, CM, CS, CS##_t, CS##_layout_t)
85 
86 
87 namespace boost { namespace gil {
88 
89 // forward declarations
90 template <typename B, typename Mn, typename Mx> struct scoped_channel_value;
91 template <typename T> struct float_point_zero;
92 template <typename T> struct float_point_one;
93 
97 
100 using std::uint8_t;
101 
104 using std::uint16_t;
105 
108 using std::uint32_t;
109 
112 using std::int8_t;
113 
116 using std::int16_t;
117 
120 using std::int32_t;
121 
124 using float32_t = scoped_channel_value<float, float_point_zero<float>, float_point_one<float>>;
125 
128 using float64_t = scoped_channel_value<double, float_point_zero<double>, float_point_one<double>>;
129 
130 GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, gray)
131 GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, gray)
132 GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, gray)
133 GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, gray)
134 GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, gray)
135 GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, gray)
136 GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, gray)
137 
138 GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, bgr)
139 GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, bgr)
140 GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, bgr)
141 GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, bgr)
142 GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, bgr)
143 GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, bgr)
144 GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, bgr)
145 
146 GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, argb)
147 GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, argb)
148 GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, argb)
149 GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, argb)
150 GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, argb)
151 GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, argb)
152 GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, argb)
153 
154 GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, abgr)
155 GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, abgr)
156 GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, abgr)
157 GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, abgr)
158 GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, abgr)
159 GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, abgr)
160 GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, abgr)
161 
162 GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, bgra)
163 GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, bgra)
164 GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, bgra)
165 GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, bgra)
166 GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, bgra)
167 GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, bgra)
168 GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, bgra)
169 
170 GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, rgb)
171 GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, rgb)
172 GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, rgb)
173 GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, rgb)
174 GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, rgb)
175 GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, rgb)
176 GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, rgb)
177 
178 GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, rgba)
179 GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, rgba)
180 GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, rgba)
181 GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, rgba)
182 GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, rgba)
183 GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, rgba)
184 GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, rgba)
185 
186 GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, cmyk)
187 GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, cmyk)
188 GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, cmyk)
189 GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, cmyk)
190 GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, cmyk)
191 GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, cmyk)
192 GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, cmyk)
193 
194 template <int N> struct devicen_t;
195 template <int N> struct devicen_layout_t;
196 
197 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
198 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
199 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
200 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
201 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
202 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
203 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
204 
205 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
206 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
207 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
208 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
209 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
210 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
211 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
212 
213 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
214 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
215 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
216 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
217 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
218 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
219 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
220 
221 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
222 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
223 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
224 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
225 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
226 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
227 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
228 
229 }} // namespace boost::gil
230 
231 #endif
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:124
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:128
Unnamed color space of 1, 3, 4, or 5 channels.
Definition: device_n.hpp:33
unnamed color layout of up to five channels
Definition: device_n.hpp:56