9#ifndef BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_ALGORITHM_HPP
10#define BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_ALGORITHM_HPP
12#include <boost/gil/extension/dynamic_image/any_image.hpp>
14#include <boost/gil/algorithm.hpp>
16#include <boost/variant2/variant.hpp>
30namespace boost {
namespace gil {
34struct equal_pixels_fn : binary_operation_obj<equal_pixels_fn, bool>
36 template <
typename V1,
typename V2>
38 bool apply_compatible(V1
const& v1, V2
const& v2)
const
49template <
typename ...Types,
typename View>
52 return variant2::visit(
53 std::bind(detail::equal_pixels_fn(), std::placeholders::_1, dst),
60template <
typename View,
typename ...Types>
63 return variant2::visit(
64 std::bind(detail::equal_pixels_fn(), src, std::placeholders::_1),
71template <
typename ...Types1,
typename ...Types2>
74 return variant2::visit(detail::equal_pixels_fn(), src, dst);
79struct copy_pixels_fn :
public binary_operation_obj<copy_pixels_fn>
81 template <
typename View1,
typename View2>
83 void apply_compatible(View1
const& src, View2
const& dst)
const
94template <
typename ...Types,
typename View>
97 variant2::visit(std::bind(detail::copy_pixels_fn(), std::placeholders::_1, dst), src);
103template <
typename ...Types,
typename View>
106 variant2::visit(std::bind(detail::copy_pixels_fn(), src, std::placeholders::_1), dst);
112template <
typename ...Types1,
typename ...Types2>
115 variant2::visit(detail::copy_pixels_fn(), src, dst);
119struct default_color_converter;
125template <
typename ...Types,
typename View,
typename CC>
128 using cc_fn = detail::copy_and_convert_pixels_fn<CC>;
129 variant2::visit(std::bind(cc_fn{cc}, std::placeholders::_1, dst), src);
135template <
typename ...Types,
typename View>
138 using cc_fn = detail::copy_and_convert_pixels_fn<default_color_converter>;
139 variant2::visit(std::bind(cc_fn{}, std::placeholders::_1, dst), src);
146template <
typename View,
typename ...Types,
typename CC>
149 using cc_fn = detail::copy_and_convert_pixels_fn<CC>;
150 variant2::visit(std::bind(cc_fn{cc}, src, std::placeholders::_1), dst);
156template <
typename View,
typename ...Types>
159 using cc_fn = detail::copy_and_convert_pixels_fn<default_color_converter>;
160 variant2::visit(std::bind(cc_fn{}, src, std::placeholders::_1), dst);
167template <
typename ...Types1,
typename ...Types2,
typename CC>
168void copy_and_convert_pixels(
172 variant2::visit(detail::copy_and_convert_pixels_fn<CC>(cc), src, dst);
168void copy_and_convert_pixels( {
…}
178template <
typename ...Types1,
typename ...Types2>
179void copy_and_convert_pixels(
184 detail::copy_and_convert_pixels_fn<default_color_converter>(), src, dst);
179void copy_and_convert_pixels( {
…}
189template <
bool IsCompatible>
190struct fill_pixels_fn1
192 template <
typename V,
typename Value>
193 static void apply(V
const& src, Value
const& val) {
fill_pixels(src, val); }
198struct fill_pixels_fn1<false>
200 template <
typename V,
typename Value>
201 static void apply(V
const&, Value
const&) {
throw std::bad_cast();}
204template <
typename Value>
207 fill_pixels_fn(Value
const& val) : val_(val) {}
209 using result_type = void;
210 template <
typename V>
211 result_type operator()(V
const&
view)
const
215 pixels_are_compatible
217 typename V::value_type,
220 >::apply(
view, val_);
231template <
typename ...Types,
typename Value>
234 variant2::visit(detail::fill_pixels_fn<Value>(val),
view);
240struct for_each_pixel_fn
242 for_each_pixel_fn(F&& fun) : fun_(std::move(fun)) {}
244 template <
typename View>
245 auto operator()(View
const&
view) -> F
247 return for_each_pixel(
view, fun_);
260template <
typename ...Types,
typename F>
261auto for_each_pixel(any_image_view<Types...>
const&
view, F fun) -> F
263 return variant2::visit(detail::for_each_pixel_fn<F>(std::move(fun)),
view);
Represents a run-time specified image view. Models HasDynamicXStepTypeConcept, HasDynamicYStepTypeCon...
Definition any_image_view.hpp:76
auto view(image< Pixel, IsPlanar, Alloc > &img) -> typename image< Pixel, IsPlanar, Alloc >::view_t const &
Returns the non-constant-pixel view of an image.
Definition image.hpp:565
BOOST_FORCEINLINE void copy_pixels(const View1 &src, const View2 &dst)
std::copy for image views
Definition algorithm.hpp:292
BOOST_FORCEINLINE bool equal_pixels(const View1 &v1, const View2 &v2)
std::equal for image views
Definition algorithm.hpp:1109
BOOST_FORCEINLINE void fill_pixels(View const &view, Value const &value)
std::fill for image views
Definition algorithm.hpp:420
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition algorithm.hpp:36