2
0
mirror of https://github.com/boostorg/gil.git synced 2026-01-26 06:32:16 +00:00
Files
gil/test/extension/io/cmp_view.hpp
Mateusz Łoskot 70ff5648d0 Replace Boost.Test with Boost.LightweightTest in test/extension/io (#464)
Move test sources to format-specific directories.
Add FIXME and TODO comments about issues discovered while building the format-specific tests.
Add missing `#include`-s with standard library headers.
Apply minor corrections and tidying up.

Continues #459
Closes #461
2020-03-24 10:21:20 +01:00

38 lines
1.1 KiB
C++

//
// Copyright 2013 Christian Henning
//
// 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
//
#ifndef BOOST_GIL_IO_TEST_EXTENSION_IO_CMP_VIEW_HPP
#define BOOST_GIL_IO_TEST_EXTENSION_IO_CMP_VIEW_HPP
#include <boost/gil.hpp>
#include <stdexcept>
template <typename View1, typename View2>
void cmp_view(View1 const& v1, View2 const& v2)
{
if (v1.dimensions() != v2.dimensions())
throw std::runtime_error("Images are not equal.");
typename View1::x_coord_t width = v1.width();
typename View1::y_coord_t height = v1.height();
for (typename View1::y_coord_t y = 0; y < height; ++y)
{
typename View1::x_iterator const src_it = v1.row_begin(y);
typename View2::x_iterator const dst_it = v2.row_begin(y);
for (typename View1::x_coord_t x = 0; x < width; ++x)
{
if (*src_it != *dst_it)
throw std::runtime_error("Images are not equal.");
}
}
}
#endif // BOOST_GIL_IO_TEST_EXTENSION_IO_CMP_VIEW_HPP