diff --git a/include/boost/gil/algorithm.hpp b/include/boost/gil/algorithm.hpp index 5c8159450..c7226fddf 100644 --- a/include/boost/gil/algorithm.hpp +++ b/include/boost/gil/algorithm.hpp @@ -765,7 +765,7 @@ F for_each_pixel(const V& img, F fun) { return std::for_each(img.begin().x(), img.end().x(), fun); } else { for (std::ptrdiff_t y=0; y +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or +# copy at http://www.boost.org/LICENSE_1_0.txt) + +import testing ; + +project + : requirements + $(BOOST_ROOT) + .. + ; + +run for_each_pixel.cpp ; diff --git a/test/algorithm/for_each_pixel.cpp b/test/algorithm/for_each_pixel.cpp new file mode 100644 index 000000000..28c5210ab --- /dev/null +++ b/test/algorithm/for_each_pixel.cpp @@ -0,0 +1,32 @@ +// +// Copyright 2018 Mateusz Loskot +// +// Distributed under the Boost Software License, Version 1.0 +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +// +#include +#include + +#include + +namespace gil = boost::gil; + +void test_lambda_expression() +{ + gil::gray8_pixel_t const gray128(128); + gil::gray8_image_t image(2, 2, gray128); + + int sum{0}; + gil::for_each_pixel(gil::view(image), [&sum](gil::gray8_pixel_t& p) { + sum += gil::at_c<0>(p); + }); + BOOST_TEST(sum == 2 * 2 * 128); +} + +int main() +{ + test_lambda_expression(); + + return boost::report_errors(); +}