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