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_SCANLINE_READ_TEST_HPP
9 #define BOOST_GIL_IO_TEST_SCANLINE_READ_TEST_HPP
10
11 #include <boost/gil.hpp>
12
13 #include "cmp_view.hpp"
14
15 template< typename Image
16 , typename FormatTag
17 >
test_scanline_reader(const char * file_name)18 void test_scanline_reader( const char* file_name )
19 {
20 using namespace boost::gil;
21
22 // read image using scanline_read_iterator
23 using reader_t = scanline_reader
24 <
25 typename get_read_device<char const*, FormatTag>::type,
26 FormatTag
27 >;
28
29 reader_t reader = make_scanline_reader( file_name, FormatTag() );
30
31 Image dst( reader._info._width, reader._info._height );
32
33 using iterator_t = typename reader_t::iterator_t;
34
35 iterator_t it = reader.begin();
36 iterator_t end = reader.end();
37
38 for( int row = 0; it != end; ++it, ++row )
39 {
40 copy_pixels( interleaved_view( reader._info._width
41 , 1
42 , ( typename Image::view_t::x_iterator ) *it
43 , reader._scanline_length
44 )
45 , subimage_view( view( dst )
46 , 0
47 , row
48 , reader._info._width
49 , 1
50 )
51 );
52 }
53
54 //compare
55 Image img;
56 read_image( file_name, img, FormatTag() );
57
58 cmp_view( view( dst ), view( img ) );
59 }
60
61 #endif // BOOST_GIL_IO_TEST_SCANLINE_READ_TEST_HPP
62