2 // Copyright 2019 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
4 // Use, modification and distribution are subject to the Boost Software License,
5 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 #include <boost/gil/image_processing/scaling.hpp>
9 #include <boost/gil/image.hpp>
11 #include <boost/core/lightweight_test.hpp>
16 namespace gil = boost::gil;
18 bool are_equal(gil::rgb8_view_t expected, gil::rgb8_view_t actual) {
19 if (expected.dimensions() != actual.dimensions())
22 for (long int y = 0; y < expected.height(); ++y)
24 for (long int x = 0; x < expected.width(); ++x)
26 if (expected(x, y) != actual(x, y))
36 void test_lanczos_black_image()
39 const gil::point_t input_dimensions(20, 20);
40 const gil::point_t output_dimensions(input_dimensions.x / 2, input_dimensions.y / 2);
41 gil::rgb8_image_t image(input_dimensions, gil::rgb8_pixel_t(0, 0, 0), 0);
42 // fill with values other than 0
43 gil::rgb8_image_t output_image(
45 gil::rgb8_pixel_t(100, 100, 100),
48 gil::rgb8_image_t expected(
50 gil::rgb8_pixel_t(0, 0, 0),
54 auto view = gil::view(image);
55 auto output_view = gil::view(output_image);
56 auto expected_view = gil::view(expected);
57 gil::scale_lanczos(view, output_view, 5);
58 BOOST_TEST(are_equal(expected_view,output_view));
61 void test_lanczos_response_on_zero()
64 BOOST_TEST(gil::lanczos(0, 2) == 1);
69 test_lanczos_black_image();
70 test_lanczos_response_on_zero();
71 return boost::report_errors();