• 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 //#define BOOST_TEST_MODULE bmp_old_test_module
9 #include <boost/gil.hpp>
10 #include <boost/gil/extension/io/bmp/old.hpp>
11 
12 #include <boost/mp11.hpp>
13 #include <boost/test/unit_test.hpp>
14 
15 #include "mandel_view.hpp"
16 #include "paths.hpp"
17 
18 using namespace std;
19 using namespace boost;
20 using namespace gil;
21 
22 BOOST_AUTO_TEST_SUITE( gil_io_bmp_tests )
23 
24 #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
25 
BOOST_AUTO_TEST_CASE(old_read_dimensions_test)26 BOOST_AUTO_TEST_CASE( old_read_dimensions_test )
27 {
28     boost::gil::point_t dim = bmp_read_dimensions(bmp_filename);
29     BOOST_CHECK_EQUAL( dim.x, 1000 );
30     BOOST_CHECK_EQUAL( dim.y, 600  );
31 }
32 
BOOST_AUTO_TEST_CASE(old_read_image_test)33 BOOST_AUTO_TEST_CASE( old_read_image_test )
34 {
35     rgb8_image_t img;
36     bmp_read_image( bmp_filename, img );
37 
38     BOOST_CHECK_EQUAL( img.width() , 1000 );
39     BOOST_CHECK_EQUAL( img.height(), 600  );
40 }
41 
BOOST_AUTO_TEST_CASE(old_read_and_convert_image_test)42 BOOST_AUTO_TEST_CASE( old_read_and_convert_image_test )
43 {
44     rgb8_image_t img;
45     bmp_read_and_convert_image( bmp_filename, img );
46 
47     BOOST_CHECK_EQUAL( img.width() , 1000 );
48     BOOST_CHECK_EQUAL( img.height(), 600  );
49 }
50 
BOOST_AUTO_TEST_CASE(old_read_view_test)51 BOOST_AUTO_TEST_CASE( old_read_view_test )
52 {
53     rgb8_image_t img( 1000, 600 );
54     bmp_read_view( bmp_filename, view( img ) );
55 }
56 
BOOST_AUTO_TEST_CASE(old_read_and_convert_view_test)57 BOOST_AUTO_TEST_CASE( old_read_and_convert_view_test )
58 {
59     rgb8_image_t img( 1000, 600 );
60     bmp_read_and_convert_view( bmp_filename, view( img ) );
61 }
62 
BOOST_AUTO_TEST_CASE(old_write_view_test)63 BOOST_AUTO_TEST_CASE( old_write_view_test )
64 {
65 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
66     bmp_write_view( bmp_out + "old_write_view_test.bmp"
67                   , create_mandel_view( 1000, 600
68                                       , rgb8_pixel_t( 0,   0, 255 )
69                                       , rgb8_pixel_t( 0, 255,   0 )
70                                       )
71                   );
72 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
73 }
74 
BOOST_AUTO_TEST_CASE(old_dynamic_image_test)75 BOOST_AUTO_TEST_CASE( old_dynamic_image_test )
76 {
77     using my_img_types = mp11::mp_list
78         <
79             gray8_image_t,
80             gray16_image_t,
81             rgb8_image_t,
82             rgba8_image_t
83         >;
84 
85     any_image< my_img_types > runtime_image;
86 
87     bmp_read_image( bmp_filename.c_str()
88                   , runtime_image
89                   );
90 
91 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
92     bmp_write_view( bmp_out + "old_dynamic_image_test.bmp"
93                   , view( runtime_image )
94                   );
95 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
96 }
97 #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
98 
99 BOOST_AUTO_TEST_SUITE_END()
100