Imported Upstream version 1.71.0
[platform/upstream/boost.git] / libs / gil / test / extension / io / color_space_write_test.hpp
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
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 >
21 void color_space_write_test( const std::string& file_name_1
22                            , const std::string& file_name_2
23                            )
24 {
25     using namespace boost::gil;
26
27     rgb8_image_t rgb( 320, 200 );
28     bgr8_image_t bgr( 320, 200 );
29
30     fill_pixels( view(rgb), rgb8_pixel_t(  0, 0, 255 ));
31     fill_pixels( view(bgr), bgr8_pixel_t(255, 0,   0 ));
32
33 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
34     write_view( file_name_1, view( rgb ), Tag() );
35     write_view( file_name_2, view( bgr ), Tag() );
36 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
37
38 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
39     rgb8_image_t rgb_1;
40     rgb8_image_t rgb_2;
41
42     read_image( file_name_1, rgb_1, Tag() );
43     read_image( file_name_2, rgb_2, Tag() );
44
45     cmp_view( view( rgb_1 ), view( rgb_2 ));
46 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
47
48 #ifndef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
49     boost::ignore_unused(file_name_1);
50     boost::ignore_unused(file_name_2);
51 #endif
52 }
53
54 #endif