1 //
2 // Copyright 2013 Christian Henning
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 #ifndef BOOST_GIL_IO_TEST_SUBIMAGE_TEST_HPP
9 #define BOOST_GIL_IO_TEST_SUBIMAGE_TEST_HPP
10
11 #include <boost/gil.hpp>
12
13 #include <boost/core/lightweight_test.hpp>
14
15 #include <string>
16
17 template <typename Image, typename Format>
run_subimage_test(std::string const & filename,boost::gil::point_t const & top_left,boost::gil::point_t const & dimension)18 void run_subimage_test(
19 std::string const& filename, boost::gil::point_t const& top_left, boost::gil::point_t const& dimension)
20 {
21 Image original, subimage;
22 boost::gil::read_image(filename, original, Format{});
23 boost::gil::image_read_settings<Format> settings(top_left, dimension);
24 boost::gil::read_image(filename, subimage, settings);
25 BOOST_TEST(boost::gil::equal_pixels(
26 boost::gil::const_view(subimage),
27 boost::gil::subimage_view(boost::gil::const_view(original), top_left, dimension)));
28 }
29
30 #endif // BOOST_GIL_IO_TEST_SUBIMAGE_TEST_HPP
31