color_space_write_test.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_COLOR_SPACE_WRITE_TEST_HPP
  9. #define BOOST_GIL_IO_TEST_COLOR_SPACE_WRITE_TEST_HPP
  10. #include <boost/gil.hpp>
  11. #ifndef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  12. #include <boost/core/ignore_unused.hpp>
  13. #endif
  14. #include <string>
  15. #include "cmp_view.hpp"
  16. template< typename Tag >
  17. void color_space_write_test( const std::string& file_name_1
  18. , const std::string& file_name_2
  19. )
  20. {
  21. using namespace boost::gil;
  22. rgb8_image_t rgb( 320, 200 );
  23. bgr8_image_t bgr( 320, 200 );
  24. fill_pixels( view(rgb), rgb8_pixel_t( 0, 0, 255 ));
  25. fill_pixels( view(bgr), bgr8_pixel_t(255, 0, 0 ));
  26. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  27. write_view( file_name_1, view( rgb ), Tag() );
  28. write_view( file_name_2, view( bgr ), Tag() );
  29. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  30. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  31. rgb8_image_t rgb_1;
  32. rgb8_image_t rgb_2;
  33. read_image( file_name_1, rgb_1, Tag() );
  34. read_image( file_name_2, rgb_2, Tag() );
  35. cmp_view( view( rgb_1 ), view( rgb_2 ));
  36. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  37. #ifndef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  38. boost::ignore_unused(file_name_1);
  39. boost::ignore_unused(file_name_2);
  40. #endif
  41. }
  42. #endif