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_EXTENSION_IO_CMP_VIEW_HPP 9 #define BOOST_GIL_IO_TEST_EXTENSION_IO_CMP_VIEW_HPP 10 11 #include <boost/gil.hpp> 12 13 #include <stdexcept> 14 15 template <typename View1, typename View2> cmp_view(View1 const & v1,View2 const & v2)16void cmp_view(View1 const& v1, View2 const& v2) 17 { 18 if (v1.dimensions() != v2.dimensions()) 19 throw std::runtime_error("Images are not equal."); 20 21 typename View1::x_coord_t width = v1.width(); 22 typename View1::y_coord_t height = v1.height(); 23 24 for (typename View1::y_coord_t y = 0; y < height; ++y) 25 { 26 typename View1::x_iterator const src_it = v1.row_begin(y); 27 typename View2::x_iterator const dst_it = v2.row_begin(y); 28 29 for (typename View1::x_coord_t x = 0; x < width; ++x) 30 { 31 if (*src_it != *dst_it) 32 throw std::runtime_error("Images are not equal."); 33 } 34 } 35 } 36 37 #endif // BOOST_GIL_IO_TEST_EXTENSION_IO_CMP_VIEW_HPP 38