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/old.hpp>
10
11 #include <boost/mp11.hpp>
12 #include <boost/core/lightweight_test.hpp>
13
14 #include "paths.hpp"
15
16 namespace gil = boost::gil;
17 namespace mp11 = boost::mp11;
18
19 #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
test_old_read_dimensions()20 void test_old_read_dimensions()
21 {
22 boost::gil::point_t dim = gil::pnm_read_dimensions(pnm_filename);
23 BOOST_TEST_EQ(dim.x, 256);
24 BOOST_TEST_EQ(dim.y, 256);
25 }
26
test_old_read_image()27 void test_old_read_image()
28 {
29 gil::rgb8_image_t img;
30 gil::pnm_read_image(pnm_filename, img);
31
32 BOOST_TEST_EQ(img.width(), 256);
33 BOOST_TEST_EQ(img.height(), 256);
34 }
35
test_old_read_and_convert_image()36 void test_old_read_and_convert_image()
37 {
38 gil::rgb8_image_t img;
39 gil::pnm_read_and_convert_image(pnm_filename, img);
40
41 BOOST_TEST_EQ(img.width(), 256);
42 BOOST_TEST_EQ(img.height(), 256);
43 }
44
test_old_read_view()45 void test_old_read_view()
46 {
47 gil::rgb8_image_t img(256, 256);
48 gil::pnm_read_view(pnm_filename, gil::view(img));
49 }
50
test_old_read_and_convert_view()51 void test_old_read_and_convert_view()
52 {
53 gil::rgb8_image_t img(256, 256);
54 gil::pnm_read_and_convert_view(pnm_filename, gil::view(img));
55 }
56
test_old_write_view()57 void test_old_write_view()
58 {
59 std::string filename(pnm_out + "test5.pnm");
60 gil::gray8_image_t img(256, 256);
61
62 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
63 gil::pnm_write_view(filename, gil::view(img));
64 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
65 }
66
test_old_dynamic_image()67 void test_old_dynamic_image()
68 {
69 using my_img_types =
70 mp11::mp_list<gil::gray8_image_t, gil::gray16_image_t, gil::rgb8_image_t, gil::gray1_image_t>;
71
72 gil::any_image<my_img_types> image;
73
74 gil::pnm_read_image(pnm_filename.c_str(), image);
75
76 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
77 gil::pnm_write_view(pnm_out + "old_dynamic_image_test.pnm", gil::view(image));
78 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
79 }
80
main()81 int main()
82 {
83 test_old_read_dimensions();
84 test_old_read_image();
85 test_old_read_and_convert_image();
86 test_old_read_view();
87 test_old_read_and_convert_view();
88 test_old_write_view();
89 test_old_dynamic_image();
90
91 return boost::report_errors();
92 }
93
94 #else
main()95 int main() {}
96 #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
97