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 #include <boost/gil.hpp>
9 #include <boost/gil/extension/io/pnm.hpp>
10
11 #include <boost/core/lightweight_test.hpp>
12
13 #include "color_space_write_test.hpp"
14 #include "mandel_view.hpp"
15 #include "paths.hpp"
16
17 namespace gil = boost::gil;;
18
19 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
test_write()20 void test_write()
21 {
22 mandel_view<gil::rgb8_pixel_t>::type v =
23 create_mandel_view(200, 200, gil::rgb8_pixel_t(0, 0, 255), gil::rgb8_pixel_t(0, 255, 0));
24
25 // test writing all supported image types
26 {
27 using gray1_image_t = gil::bit_aligned_image1_type<1, gil::gray_layout_t>::type;
28 gray1_image_t dst(200, 200);
29 gil::copy_and_convert_pixels(v, gil::view(dst));
30
31 gil::write_view(pnm_out + "p4_write_test.pnm", gil::view(dst), gil::pnm_tag());
32 }
33 {
34 gil::gray8_image_t dst(200, 200);
35 gil::copy_and_convert_pixels(v, gil::view(dst));
36
37 gil::write_view(pnm_out + "p5_write_test.pnm", gil::view(dst), gil::pnm_tag());
38 }
39 {
40 gil::write_view(pnm_out + "p6_write_test.pnm", v, gil::pnm_tag());
41 }
42 }
43 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
44
test_rgb_color_space_write()45 void test_rgb_color_space_write()
46 {
47 color_space_write_test<gil::pnm_tag>(
48 pnm_out + "rgb_color_space_test.pnm", pnm_out + "bgr_color_space_test.pnm");
49 }
50
main()51 int main()
52 {
53 test_rgb_color_space_write();
54
55 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
56 test_write();
57 #endif
58
59 return boost::report_errors();
60 }
61