• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TEST_EXTENSION_IO_COLOR_SPACE_WRITE_TEST_HPP
9 #define BOOST_GIL_TEST_EXTENSION_IO_COLOR_SPACE_WRITE_TEST_HPP
10 
11 #include <boost/gil.hpp>
12 
13 #ifndef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
14 #include <boost/core/ignore_unused.hpp>
15 #endif
16 #include <string>
17 
18 #include "cmp_view.hpp"
19 
20 template <typename Tag>
color_space_write_test(std::string const & file_name_1,std::string const & file_name_2)21 void color_space_write_test(std::string const& file_name_1, std::string const& file_name_2)
22 {
23     namespace gil = boost::gil;
24 
25     gil::rgb8_image_t rgb(320, 200);
26     gil::bgr8_image_t bgr(320, 200);
27 
28     gil::fill_pixels(gil::view(rgb), gil::rgb8_pixel_t(0, 0, 255));
29     gil::fill_pixels(gil::view(bgr), gil::bgr8_pixel_t(255, 0, 0));
30 
31 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
32     gil::write_view(file_name_1, gil::view(rgb), Tag());
33     gil::write_view(file_name_2, gil::view(bgr), Tag());
34 #endif  // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
35 
36 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
37     gil::rgb8_image_t rgb_1;
38     gil::rgb8_image_t rgb_2;
39 
40     gil::read_image(file_name_1, rgb_1, Tag());
41     gil::read_image(file_name_2, rgb_2, Tag());
42 
43     cmp_view(gil::view(rgb_1), gil::view(rgb_2));
44 #endif  // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
45 
46 #ifndef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
47     boost::ignore_unused(file_name_1);
48     boost::ignore_unused(file_name_2);
49 #endif
50 }
51 
52 #endif // BOOST_GIL_TEST_EXTENSION_IO_COLOR_SPACE_WRITE_TEST_HPP
53