Boost GIL


typedefs.hpp
Go to the documentation of this file.
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 
16 
17 #include "gil_config.hpp"
18 
19 #include <cstdint>
20 #include <memory>
21 
22 #include "cmyk.hpp"
23 #include "device_n.hpp"
24 #include "gray.hpp"
25 #include "rgb.hpp"
26 #include "rgba.hpp"
27 
28 // B - bits size/signedness, CM - channel model, CS - colour space, LAYOUT - pixel layout
29 // Example: B = '8', CM = 'uint8_t', CS = 'bgr, LAYOUT='bgr_layout_t'
30 #define GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(B, CM, CS, LAYOUT) \
31  template <typename, typename> struct pixel; \
32  template <typename, typename> struct planar_pixel_reference; \
33  template <typename, typename> struct planar_pixel_iterator; \
34  template <typename> class memory_based_step_iterator; \
35  template <typename> class point2; \
36  template <typename> class memory_based_2d_locator; \
37  template <typename> class image_view; \
38  template <typename, bool, typename> class image; \
39  using CS##B##_pixel_t = pixel<CM, LAYOUT>; \
40  using CS##B##c_pixel_t = pixel<CM, LAYOUT> const; \
41  using CS##B##_ref_t = pixel<CM, LAYOUT>&; \
42  using CS##B##c_ref_t = pixel<CM, LAYOUT> const&; \
43  using CS##B##_ptr_t = CS##B##_pixel_t*; \
44  using CS##B##c_ptr_t = CS##B##c_pixel_t*; \
45  using CS##B##_step_ptr_t = memory_based_step_iterator<CS##B##_ptr_t>; \
46  using CS##B##c_step_ptr_t = memory_based_step_iterator<CS##B##c_ptr_t>; \
47  using CS##B##_loc_t \
48  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_ptr_t>>; \
49  using CS##B##c_loc_t \
50  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_ptr_t>>; \
51  using CS##B##_step_loc_t \
52  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_step_ptr_t>>; \
53  using CS##B##c_step_loc_t \
54  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_step_ptr_t>>; \
55  using CS##B##_view_t = image_view<CS##B##_loc_t>; \
56  using CS##B##c_view_t = image_view<CS##B##c_loc_t>; \
57  using CS##B##_step_view_t = image_view<CS##B##_step_loc_t>; \
58  using CS##B##c_step_view_t = image_view<CS##B##c_step_loc_t>; \
59  using CS##B##_image_t = image<CS##B##_pixel_t, false, std::allocator<unsigned char>>;
60 
61 // Example: B = '8', CM = 'uint8_t', CS = 'bgr' CS_FULL = 'rgb_t' LAYOUT='bgr_layout_t'
62 #define GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(B, CM, CS, CS_FULL, LAYOUT) \
63  GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(B, CM, CS, LAYOUT) \
64  using CS##B##_planar_ref_t = planar_pixel_reference<CM&, CS_FULL>; \
65  using CS##B##c_planar_ref_t = planar_pixel_reference<CM const&, CS_FULL>; \
66  using CS##B##_planar_ptr_t = planar_pixel_iterator<CM*, CS_FULL>; \
67  using CS##B##c_planar_ptr_t = planar_pixel_iterator<CM const*, CS_FULL>; \
68  using CS##B##_planar_step_ptr_t = memory_based_step_iterator<CS##B##_planar_ptr_t>; \
69  using CS##B##c_planar_step_ptr_t \
70  = memory_based_step_iterator<CS##B##c_planar_ptr_t>; \
71  using CS##B##_planar_loc_t \
72  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_planar_ptr_t>>; \
73  using CS##B##c_planar_loc_t \
74  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_planar_ptr_t>>; \
75  using CS##B##_planar_step_loc_t \
76  = memory_based_2d_locator<memory_based_step_iterator<CS##B##_planar_step_ptr_t>>; \
77  using CS##B##c_planar_step_loc_t \
78  = memory_based_2d_locator<memory_based_step_iterator<CS##B##c_planar_step_ptr_t>>; \
79  using CS##B##_planar_view_t = image_view<CS##B##_planar_loc_t>; \
80  using CS##B##c_planar_view_t = image_view<CS##B##c_planar_loc_t>; \
81  using CS##B##_planar_step_view_t = image_view<CS##B##_planar_step_loc_t>; \
82  using CS##B##c_planar_step_view_t = image_view<CS##B##c_planar_step_loc_t>; \
83  using CS##B##_planar_image_t \
84  = image<CS##B##_pixel_t, true, std::allocator<unsigned char>>;
85 
86 #define GIL_DEFINE_BASE_TYPEDEFS(B, CM, CS) \
87  GIL_DEFINE_BASE_TYPEDEFS_INTERNAL(B, CM, CS, CS##_layout_t)
88 
89 #define GIL_DEFINE_ALL_TYPEDEFS(B, CM, CS) \
90  GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(B, CM, CS, CS##_t, CS##_layout_t)
91 
92 
93 namespace boost { namespace gil {
94 
95 // forward declarations
96 template <typename B, typename Mn, typename Mx> struct scoped_channel_value;
97 template <typename T> struct float_point_zero;
98 template <typename T> struct float_point_one;
99 
103 
106 using std::uint8_t;
107 
110 using std::uint16_t;
111 
114 using std::uint32_t;
115 
118 using std::int8_t;
119 
122 using std::int16_t;
123 
126 using std::int32_t;
127 
131 
135 
136 GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, gray)
137 GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, gray)
138 GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, gray)
139 GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, gray)
140 GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, gray)
141 GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, gray)
142 GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, gray)
143 
144 GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, bgr)
145 GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, bgr)
146 GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, bgr)
147 GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, bgr)
148 GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, bgr)
149 GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, bgr)
150 GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, bgr)
151 
152 GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, argb)
153 GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, argb)
154 GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, argb)
155 GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, argb)
156 GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, argb)
157 GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, argb)
158 GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, argb)
159 
160 GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, abgr)
161 GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, abgr)
162 GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, abgr)
163 GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, abgr)
164 GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, abgr)
165 GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, abgr)
166 GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, abgr)
167 
168 GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, bgra)
169 GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, bgra)
170 GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, bgra)
171 GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, bgra)
172 GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, bgra)
173 GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, bgra)
174 GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, bgra)
175 
176 GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, rgb)
177 GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, rgb)
178 GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, rgb)
179 GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, rgb)
180 GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, rgb)
181 GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, rgb)
182 GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, rgb)
183 
184 GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, rgba)
185 GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, rgba)
186 GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, rgba)
187 GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, rgba)
188 GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, rgba)
189 GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, rgba)
190 GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, rgba)
191 
192 GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, cmyk)
193 GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, cmyk)
194 GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, cmyk)
195 GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, cmyk)
196 GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, cmyk)
197 GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, cmyk)
198 GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, cmyk)
199 
200 template <int N> struct devicen_t;
201 template <int N> struct devicen_layout_t;
202 
203 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
204 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
205 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
206 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
207 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
208 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
209 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
210 
211 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
212 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
213 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
214 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
215 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
216 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
217 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
218 
219 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
220 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
221 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
222 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
223 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
224 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
225 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
226 
227 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
228 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
229 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
230 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
231 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
232 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
233 GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
234 
235 }} // namespace boost::gil
236 
237 #endif
Support for color space of N channels and variants.
Support for grayscale color space and variants.
A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept.
Definition: channel.hpp:156
Support for CMYK color space and variants.
GIL configuration file.
Support for RGB color space and variants.
unnamed color layout of up to five channels
Definition: device_n.hpp:65
Support for RGBA color space and variants.