• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/bmp/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 
test_old_read_dimensions()20 void test_old_read_dimensions()
21 {
22     boost::gil::point_t dim = gil::bmp_read_dimensions(bmp_filename);
23     BOOST_TEST_EQ(dim.x, 1000);
24     BOOST_TEST_EQ(dim.y, 600);
25 }
26 
test_old_read_image()27 void test_old_read_image()
28 {
29     gil::rgb8_image_t img;
30     gil::bmp_read_image(bmp_filename, img);
31 
32     BOOST_TEST_EQ(img.width(), 1000);
33     BOOST_TEST_EQ(img.height(), 600);
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::bmp_read_and_convert_image(bmp_filename, img);
40 
41     BOOST_TEST_EQ(img.width(), 1000);
42     BOOST_TEST_EQ(img.height(), 600);
43 }
44 
test_old_read_view()45 void test_old_read_view()
46 {
47     gil::rgb8_image_t img(1000, 600);
48     gil::bmp_read_view(bmp_filename, 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(1000, 600);
54     gil::bmp_read_and_convert_view(bmp_filename, view(img));
55 }
56 
test_old_write_view()57 void test_old_write_view()
58 {
59     auto b = gil::rgb8_pixel_t(0, 0, 255);
60     auto g = gil::rgb8_pixel_t(0, 255, 0);
61     gil::bmp_write_view(bmp_out + "old_write_view_test.bmp", create_mandel_view(1000, 600, b, g));
62 }
63 
test_old_dynamic_image()64 void test_old_dynamic_image()
65 {
66     using my_img_types = mp11::mp_list
67     <
68         gil::gray8_image_t,
69         gil::gray16_image_t,
70         gil::rgb8_image_t,
71         gil::rgba8_image_t
72     >;
73 
74     gil::any_image<my_img_types> image;
75     gil::bmp_read_image(bmp_filename.c_str(), image);
76 
77     gil::bmp_write_view(bmp_out + "old_dynamic_image_test.bmp", gil::view(image));
78 }
79 
main(int argc,char * argv[])80 int main(int argc, char *argv[])
81 {
82     try
83     {
84         test_old_read_dimensions();
85         test_old_read_image();
86         test_old_read_and_convert_image();
87         test_old_read_view();
88         test_old_read_and_convert_view();
89         test_old_write_view();
90         test_old_dynamic_image();
91     }
92     catch (std::exception const& e)
93     {
94         BOOST_ERROR(e.what());
95     }
96     return boost::report_errors();
97 }
98