scanline_read_test.hpp 1.7 KB

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