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 //#define BOOST_TEST_MODULE pnm_write_test_module
9
10 #include <boost/gil/extension/io/pnm.hpp>
11
12 #include <boost/test/unit_test.hpp>
13
14 #include "color_space_write_test.hpp"
15 #include "mandel_view.hpp"
16 #include "paths.hpp"
17
18 using namespace std;
19 using namespace boost::gil;
20
21 using tag_t = pnm_tag;
22
23 BOOST_AUTO_TEST_SUITE( gil_io_pnm_tests )
24
25 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
BOOST_AUTO_TEST_CASE(write_test)26 BOOST_AUTO_TEST_CASE( write_test )
27 {
28 mandel_view< rgb8_pixel_t >::type v = create_mandel_view( 200, 200
29 , rgb8_pixel_t( 0, 0, 255 )
30 , rgb8_pixel_t( 0, 255, 0 )
31 );
32
33 // test writing all supported image types
34 {
35 using gray1_image_t = bit_aligned_image1_type<1, gray_layout_t>::type;
36 gray1_image_t dst( 200, 200 );
37
38 copy_and_convert_pixels( v, view( dst ));
39
40 write_view( pnm_out + "p4_write_test.pnm"
41 , view( dst )
42 , pnm_tag()
43 );
44 }
45
46 {
47 gray8_image_t dst( 200, 200 );
48
49 copy_and_convert_pixels( v, view( dst ));
50
51 write_view( pnm_out + "p5_write_test.pnm"
52 , view( dst )
53 , pnm_tag()
54 );
55 }
56
57 {
58 write_view( pnm_out + "p6_write_test.pnm"
59 , v
60 , pnm_tag()
61 );
62 }
63 }
64 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
65
BOOST_AUTO_TEST_CASE(rgb_color_space_write_test)66 BOOST_AUTO_TEST_CASE( rgb_color_space_write_test )
67 {
68 color_space_write_test< pnm_tag >( pnm_out + "rgb_color_space_test.pnm"
69 , pnm_out + "bgr_color_space_test.pnm"
70 );
71 }
72
73 BOOST_AUTO_TEST_SUITE_END()
74