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>
30 namespace boost {
namespace gil {
34 struct 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
49 template <
typename ...Types,
typename View>
52 return variant2::visit(
53 std::bind(detail::equal_pixels_fn(), std::placeholders::_1, dst),
60 template <
typename View,
typename ...Types>
63 return variant2::visit(
64 std::bind(detail::equal_pixels_fn(), src, std::placeholders::_1),
71 template <
typename ...Types1,
typename ...Types2>
74 return variant2::visit(detail::equal_pixels_fn(), src, dst);
79 struct 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
94 template <
typename ...Types,
typename View>
97 variant2::visit(std::bind(detail::copy_pixels_fn(), std::placeholders::_1, dst), src);
103 template <
typename ...Types,
typename View>
106 variant2::visit(std::bind(detail::copy_pixels_fn(), src, std::placeholders::_1), dst);
112 template <
typename ...Types1,
typename ...Types2>
115 variant2::visit(detail::copy_pixels_fn(), src, dst);
119 struct default_color_converter;
125 template <
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);
135 template <
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);
146 template <
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);
156 template <
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);
167 template <
typename ...Types1,
typename ...Types2,
typename CC>
172 variant2::visit(detail::copy_and_convert_pixels_fn<CC>(cc), src, dst);
178 template <
typename ...Types1,
typename ...Types2>
184 detail::copy_and_convert_pixels_fn<default_color_converter>(), src, dst);
189 template <
bool IsCompatible>
190 struct fill_pixels_fn1
192 template <
typename V,
typename Value>
193 static void apply(V
const& src, Value
const& val) {
fill_pixels(src, val); }
198 struct fill_pixels_fn1<false>
200 template <
typename V,
typename Value>
201 static void apply(V
const&, Value
const&) {
throw std::bad_cast();}
204 template <
typename Value>
205 struct fill_pixels_fn
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_);
231 template <
typename ...Types,
typename Value>
234 variant2::visit(detail::fill_pixels_fn<Value>(val),
view);
239 template <
typename F>
240 struct 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_);
260 template <
typename ...Types,
typename F>
261 auto 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
void copy_and_convert_pixels(any_image_view< Types1... > const &src, any_image_view< Types2... > const &dst)
Definition: extension/dynamic_image/algorithm.hpp:179
void copy_pixels(any_image_view< Types1... > const &src, any_image_view< Types2... > const &dst)
Definition: extension/dynamic_image/algorithm.hpp:113
auto equal_pixels(any_image_view< Types1... > const &src, any_image_view< Types2... > const &dst) -> bool
Definition: extension/dynamic_image/algorithm.hpp:72
void fill_pixels(any_image_view< Types... > const &view, Value const &val)
fill_pixels for any image view. The pixel to fill with must be compatible with the current view
Definition: extension/dynamic_image/algorithm.hpp:232
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36