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/png/old.hpp>
10
11 #include <boost/mp11.hpp>
12 #include <boost/core/lightweight_test.hpp>
13
14 #include "mandel_view.hpp"
15 #include "paths.hpp"
16
17 namespace gil = boost::gil;
18 namespace mp11 = boost::mp11;
19
20 #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
21
test_old_read_dimensions()22 void test_old_read_dimensions()
23 {
24 gil::point_t dim = gil::png_read_dimensions(png_filename);
25 BOOST_TEST_EQ(dim.x, 1000);
26 BOOST_TEST_EQ(dim.y, 600);
27 }
28
test_old_read_image()29 void test_old_read_image()
30 {
31 gil::rgba8_image_t img;
32 gil::png_read_image(png_filename, img);
33
34 BOOST_TEST_EQ(img.width(), 1000);
35 BOOST_TEST_EQ(img.height(), 600);
36 }
37
test_old_read_and_convert_image()38 void test_old_read_and_convert_image()
39 {
40 gil::rgb8_image_t img;
41 gil::png_read_and_convert_image(png_filename, img);
42
43 BOOST_TEST_EQ(img.width(), 1000);
44 BOOST_TEST_EQ(img.height(), 600);
45 }
46
test_old_read_view()47 void test_old_read_view()
48 {
49 gil::rgba8_image_t img(1000, 600);
50 gil::png_read_view(png_filename, view(img));
51 }
52
test_old_read_and_convert_view()53 void test_old_read_and_convert_view()
54 {
55 gil::rgb8_image_t img(1000, 600);
56 gil::png_read_and_convert_view(png_filename, view(img));
57 }
58
test_old_write_view()59 void test_old_write_view()
60 {
61 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
62 gil::png_write_view(
63 png_out + "old_write_view_test.png",
64 create_mandel_view(320, 240, gil::rgb8_pixel_t(0, 0, 255), gil::rgb8_pixel_t(0, 255, 0)));
65 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
66 }
67
test_old_dynamic_image()68 void test_old_dynamic_image()
69 {
70 using my_img_types = mp11::mp_list
71 <
72 gil::gray8_image_t,
73 gil::gray16_image_t,
74 gil::rgb8_image_t,
75 gil::rgba8_image_t
76 >;
77 gil::any_image<my_img_types> image;
78
79 gil::png_read_image(png_filename.c_str(), image);
80
81 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
82 gil::png_write_view(png_out + "old_dynamic_image_test.png", gil::view(image));
83 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
84 }
85
main()86 int main()
87 {
88 test_old_read_dimensions();
89 test_old_read_image();
90 test_old_read_and_convert_image();
91 test_old_read_view();
92 test_old_read_and_convert_view();
93 test_old_write_view();
94 test_old_dynamic_image();
95
96 return boost::report_errors();
97 }
98
99 #else
main()100 int main() {}
101 #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
102