Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / test / extension / io / cmp_view.hpp
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_CMP_VIEW_HPP
9 #define BOOST_GIL_IO_TEST_CMP_VIEW_HPP
10
11 #include <boost/gil.hpp>
12
13 template< typename View_1, typename View_2 >
14 void cmp_view( const View_1& v1
15              , const View_2& v2
16              )
17 {
18     if( v1.dimensions() != v2.dimensions() )
19     {
20         throw std::runtime_error( "Images are not equal." );
21     }
22
23     typename View_1::x_coord_t width  = v1.width();
24     typename View_1::y_coord_t height = v1.height();
25
26     for( typename View_1::y_coord_t y = 0; y < height; ++y )
27     {
28         const typename View_1::x_iterator src_it = v1.row_begin( y );
29         const typename View_2::x_iterator dst_it = v2.row_begin( y );
30
31         for( typename View_1::x_coord_t x = 0; x < width; ++x )
32         {
33             if( *src_it != *dst_it )
34             {
35                 throw std::runtime_error( "Images are not equal." );
36             }
37         }
38     }
39 }
40
41 #endif