Generic Image Library: typedefs.hpp Source File

###  | #  |

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
116namespace boost { namespace gil {
117
118// forward declarations
119template <typename B, typename Mn, typename Mx> struct scoped_channel_value;
120template <typename T> struct float_point_zero;
121template <typename T> struct float_point_one;
122
126
129using std::uint8_t;
130
133using std::uint16_t;
134
137using std::uint32_t;
138
141using std::int8_t;
142
145using std::int16_t;
146
149using 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
159BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, gray)
160BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, gray)
161BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, gray)
162BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, gray)
163BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, gray)
164BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, gray)
165BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, gray)
166
167BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, bgr)
168BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, bgr)
169BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, bgr)
170BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, bgr)
171BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, bgr)
172BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, bgr)
173BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, bgr)
174
175BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, argb)
176BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, argb)
177BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, argb)
178BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, argb)
179BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, argb)
180BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, argb)
181BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, argb)
182
183BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, abgr)
184BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, abgr)
185BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, abgr)
186BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, abgr)
187BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, abgr)
188BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, abgr)
189BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, abgr)
190
191BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, bgra)
192BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, bgra)
193BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, bgra)
194BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, bgra)
195BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, bgra)
196BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, bgra)
197BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, bgra)
198
199BOOST_GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, rgb)
200BOOST_GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, rgb)
201BOOST_GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, rgb)
202BOOST_GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, rgb)
203BOOST_GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, rgb)
204BOOST_GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, rgb)
205BOOST_GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, rgb)
206
207BOOST_GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, rgba)
208BOOST_GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, rgba)
209BOOST_GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, rgba)
210BOOST_GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, rgba)
211BOOST_GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, rgba)
212BOOST_GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, rgba)
213BOOST_GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, rgba)
214
215BOOST_GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, cmyk)
216BOOST_GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, cmyk)
217BOOST_GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, cmyk)
218BOOST_GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, cmyk)
219BOOST_GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, cmyk)
220BOOST_GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, cmyk)
221BOOST_GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, cmyk)
222
223template <int N> struct devicen_t;
224template <int N> struct devicen_layout_t;
225
226BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
227BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
228BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
229BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
230BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
231BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
232BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev2n, devicen_t<2>, devicen_layout_t<2>)
233
234BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
235BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
236BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
237BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
238BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
239BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
240BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev3n, devicen_t<3>, devicen_layout_t<3>)
241
242BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
243BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
244BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
245BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
246BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
247BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
248BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev4n, devicen_t<4>, devicen_layout_t<4>)
249
250BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8, uint8_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
251BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(8s, int8_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
252BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16, uint16_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
253BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(16s, int16_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
254BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32, uint32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
255BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32s, int32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
256BOOST_GIL_DEFINE_ALL_TYPEDEFS_INTERNAL(32f, float32_t, dev5n, devicen_t<5>, devicen_layout_t<5>)
257
258}} // namespace boost::gil
259
260#endif
boost::gil::float64_t
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
boost::gil::float32_t
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
boost
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition algorithm.hpp:36
boost::gil::devicen_layout_t
unnamed color layout of up to five channels
Definition device_n.hpp:56
boost::gil::devicen_t
Unnamed color space of 1, 2, 3, 4, or 5 channels.
Definition device_n.hpp:40