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>
20namespace boost {
namespace gil {
27template <
typename ResultView>
28struct flipped_up_down_view_fn
30 using result_type = ResultView;
32 template <
typename View>
33 auto operator()(View
const& src)
const -> result_type
35 return result_type{flipped_up_down_view(src)};
39template <
typename ResultView>
40struct flipped_left_right_view_fn
42 using result_type = ResultView;
44 template <
typename View>
45 auto operator()(View
const& src)
const -> result_type
47 return result_type{flipped_left_right_view(src)};
51template <
typename ResultView>
52struct rotated90cw_view_fn
54 using result_type = ResultView;
56 template <
typename View>
57 auto operator()(View
const& src)
const -> result_type
59 return result_type{rotated90cw_view(src)};
63template <
typename ResultView>
64struct rotated90ccw_view_fn
66 using result_type = ResultView;
68 template <
typename View>
69 auto operator()(View
const& src)
const -> result_type
71 return result_type{rotated90ccw_view(src)};
75template <
typename ResultView>
76struct transposed_view_fn
78 using result_type = ResultView;
80 template <
typename View>
81 auto operator()(View
const& src)
const -> result_type
83 return result_type{transposed_view(src)};
87template <
typename ResultView>
88struct rotated180_view_fn
90 using result_type = ResultView;
92 template <
typename View>
93 auto operator()(View
const& src)
const -> result_type
95 return result_type{rotated180_view(src)};
99template <
typename ResultView>
100struct 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
111 return result_type{subimage_view(src,_topleft,_size2)};
118template <
typename ResultView>
119struct 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
128 return result_type{subsampled_view(src,_step)};
134template <
typename ResultView>
135struct 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
144 return result_type(nth_channel_view(src,_n));
150template <
typename DstP,
typename ResultView,
typename CC = default_color_converter>
151struct 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)};
171template <
typename ...Views>
177 return variant2::visit(detail::flipped_up_down_view_fn<result_view_t>(), src);
182template <
typename ...Views>
188 return variant2::visit(detail::flipped_left_right_view_fn<result_view_t>(), src);
193template <
typename ...Views>
199 return variant2::visit(detail::transposed_view_fn<result_view_t>(), src);
204template <
typename ...Views>
210 return variant2::visit(detail::rotated90cw_view_fn<result_view_t>(), src);
215template <
typename ...Views>
221 return variant2::visit(detail::rotated90ccw_view_fn<result_view_t>(), src);
226template <
typename ...Views>
232 return variant2::visit(detail::rotated180_view_fn<result_view_t>(), src);
237template <
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);
239auto subimage_view( {
…}
251template <
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);
253auto subimage_view( {
…}
264template <
typename ...Views>
270 using subsampled_view = detail::subsampled_view_fn<step_type>;
271 return variant2::visit(subsampled_view(step), src);
276template <
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);
288template <
typename View>
289struct get_nthchannel_type {
using type =
typename nth_channel_view_type<View>::type; };
291template <
typename Views>
292struct views_get_nthchannel_type : mp11::mp_transform<get_nthchannel_type, Views> {};
298template <
typename ...Views>
301 using type =
typename detail::views_get_nthchannel_type<
any_image_view<Views...>>;
306template <
typename ...Views>
312 return variant2::visit(detail::nth_channel_view_fn<result_view_t>(n), src);
317template <
typename Views,
typename DstP,
typename CC>
318struct 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>;
331template <
typename ...Views,
typename DstP,
typename CC>
335 using type =
typename detail::views_get_ccv_type<
any_image_view<Views...>, DstP, CC>::type;
341template <
typename DstP,
typename ...Views,
typename CC>
347 return variant2::visit(detail::color_converted_view_fn<DstP, cc_view_t, CC>(cc), src);
352template <
typename ...Views,
typename DstP>
361template <
typename DstP,
typename ...Views>
367 return variant2::visit(detail::color_converted_view_fn<DstP, cc_view_t>(), src);
374template <
typename DstP,
typename ...Views,
typename CC>
375[[deprecated(
"Use color_converted_view(const any_image_view<Views...>& src, CC) instead.")]]
387template <
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