8 #ifndef BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_IMAGE_VIEW_FACTORY_HPP
9 #define BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_IMAGE_VIEW_FACTORY_HPP
11 #include <boost/gil/extension/dynamic_image/any_image_view.hpp>
13 #include <boost/gil/dynamic_step.hpp>
14 #include <boost/gil/image_view_factory.hpp>
15 #include <boost/gil/point.hpp>
16 #include <boost/gil/detail/mp11.hpp>
20 namespace boost {
namespace gil {
27 template <
typename ResultView>
28 struct flipped_up_down_view_fn
30 using result_type = ResultView;
32 template <
typename View>
33 auto operator()(View
const& src)
const -> result_type
39 template <
typename ResultView>
40 struct flipped_left_right_view_fn
42 using result_type = ResultView;
44 template <
typename View>
45 auto operator()(View
const& src)
const -> result_type
51 template <
typename ResultView>
52 struct rotated90cw_view_fn
54 using result_type = ResultView;
56 template <
typename View>
57 auto operator()(View
const& src)
const -> result_type
63 template <
typename ResultView>
64 struct rotated90ccw_view_fn
66 using result_type = ResultView;
68 template <
typename View>
69 auto operator()(View
const& src)
const -> result_type
75 template <
typename ResultView>
76 struct transposed_view_fn
78 using result_type = ResultView;
80 template <
typename View>
81 auto operator()(View
const& src)
const -> result_type
87 template <
typename ResultView>
88 struct rotated180_view_fn
90 using result_type = ResultView;
92 template <
typename View>
93 auto operator()(View
const& src)
const -> result_type
99 template <
typename ResultView>
100 struct subimage_view_fn
102 using result_type = ResultView;
104 subimage_view_fn(point_t
const& topleft, point_t
const& dimensions)
105 : _topleft(topleft), _size2(dimensions)
108 template <
typename View>
109 auto operator()(View
const& src)
const -> result_type
118 template <
typename ResultView>
119 struct subsampled_view_fn
121 using result_type = ResultView;
123 subsampled_view_fn(point_t
const& step) : _step(step) {}
125 template <
typename View>
126 auto operator()(View
const& src)
const -> result_type
134 template <
typename ResultView>
135 struct nth_channel_view_fn
137 using result_type = ResultView;
139 nth_channel_view_fn(
int n) : _n(n) {}
141 template <
typename View>
142 auto operator()(View
const& src)
const -> result_type
150 template <
typename DstP,
typename ResultView,
typename CC = default_color_converter>
151 struct color_converted_view_fn
153 using result_type = ResultView;
155 color_converted_view_fn(CC cc = CC()): _cc(cc) {}
157 template <
typename View>
158 auto operator()(View
const& src)
const -> result_type
160 return result_type{color_converted_view<DstP>(src, _cc)};
171 template <
typename ...Views>
177 return variant2::visit(detail::flipped_up_down_view_fn<result_view_t>(), src);
182 template <
typename ...Views>
188 return variant2::visit(detail::flipped_left_right_view_fn<result_view_t>(), src);
193 template <
typename ...Views>
199 return variant2::visit(detail::transposed_view_fn<result_view_t>(), src);
204 template <
typename ...Views>
210 return variant2::visit(detail::rotated90cw_view_fn<result_view_t>(), src);
215 template <
typename ...Views>
221 return variant2::visit(detail::rotated90ccw_view_fn<result_view_t>(), src);
226 template <
typename ...Views>
232 return variant2::visit(detail::rotated180_view_fn<result_view_t>(), src);
237 template <
typename ...Views>
245 using subimage_view_fn = detail::subimage_view_fn<
any_image_view<Views...>>;
246 return variant2::visit(subimage_view_fn(topleft, dimensions), src);
251 template <
typename ...Views>
255 std::ptrdiff_t x_min, std::ptrdiff_t y_min, std::ptrdiff_t width, std::ptrdiff_t height)
258 using subimage_view_fn = detail::subimage_view_fn<
any_image_view<Views...>>;
259 return variant2::visit(subimage_view_fn(
point_t(x_min, y_min),
point_t(width, height)), src);
264 template <
typename ...Views>
276 template <
typename ...Views>
282 using subsampled_view_fn = detail::subsampled_view_fn<step_type>;
283 return variant2::visit(subsampled_view_fn(
point_t(x_step, y_step)), src);
288 template <
typename View>
289 struct get_nthchannel_type {
using type =
typename nth_channel_view_type<View>::type; };
291 template <
typename Views>
292 struct views_get_nthchannel_type : mp11::mp_transform<get_nthchannel_type, Views> {};
298 template <
typename ...Views>
301 using type =
typename detail::views_get_nthchannel_type<
any_image_view<Views...>>;
306 template <
typename ...Views>
312 return variant2::visit(detail::nth_channel_view_fn<result_view_t>(n), src);
317 template <
typename Views,
typename DstP,
typename CC>
318 struct views_get_ccv_type
321 template <
typename T>
322 using ccvt =
typename color_converted_view_type<T, DstP, CC>::type;
324 using type = mp11::mp_transform<ccvt, Views>;
331 template <
typename ...Views,
typename DstP,
typename CC>
335 using type =
typename detail::views_get_ccv_type<
any_image_view<Views...>, DstP, CC>::type;
341 template <
typename DstP,
typename ...Views,
typename CC>
347 return variant2::visit(detail::color_converted_view_fn<DstP, cc_view_t, CC>(cc), src);
352 template <
typename ...Views,
typename DstP>
361 template <
typename DstP,
typename ...Views>
367 return variant2::visit(detail::color_converted_view_fn<DstP, cc_view_t>(), src);
374 template <
typename DstP,
typename ...Views,
typename CC>
375 [[deprecated(
"Use color_converted_view(const any_image_view<Views...>& src, CC) instead.")]]
387 template <
typename DstP,
typename ...Views>
388 [[deprecated(
"Use color_converted_view(any_image_view<Views...> const& src) instead.")]]
Represents a run-time specified image view. Models HasDynamicXStepTypeConcept, HasDynamicYStepTypeCon...
Definition: any_image_view.hpp:76
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36
Returns the type of a view that does color conversion upon dereferencing its pixels.
Definition: image_view_factory.hpp:176
class for color-converting one pixel to another
Definition: color_convert.hpp:328
Base template for types that model HasDynamicXStepTypeConcept.
Definition: dynamic_step.hpp:17
Returns the type of a transposed view that has a dynamic step along both X and Y.
Definition: image_view_factory.hpp:52
Returns the type of a view that has a dynamic step along both X and Y.
Definition: image_view_factory.hpp:46
Base template for types that model HasDynamicYStepTypeConcept.
Definition: dynamic_step.hpp:21
Given a source image view type View, returns the type of an image view over a single channel of View.
Definition: image_view_factory.hpp:437