• 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/targa/old.hpp>
10 
11 #include <boost/core/lightweight_test.hpp>
12 #include <boost/mp11.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::targa_read_dimensions(targa_filename);
23 
24     BOOST_TEST_EQ(dim.x, 124);
25     BOOST_TEST_EQ(dim.y, 124);
26 }
27 
test_old_read_image()28 void test_old_read_image()
29 {
30     gil::rgb8_image_t img;
31     gil::targa_read_image(targa_filename, img);
32 
33     BOOST_TEST_EQ(img.width(), 124);
34     BOOST_TEST_EQ(img.height(), 124);
35 }
36 
test_old_read_and_convert_image()37 void test_old_read_and_convert_image()
38 {
39     gil::rgb8_image_t img;
40     gil::targa_read_and_convert_image(targa_filename, img);
41 
42     BOOST_TEST_EQ(img.width(), 124);
43     BOOST_TEST_EQ(img.height(), 124);
44 }
45 
test_old_read_view()46 void test_old_read_view()
47 {
48     gil::rgb8_image_t img(124, 124);
49     gil::targa_read_view(targa_filename, gil::view(img));
50 }
51 
test_old_read_and_convert_view()52 void test_old_read_and_convert_view()
53 {
54     gil::rgb8_image_t img(124, 124);
55     gil::targa_read_and_convert_view(targa_filename, gil::view(img));
56 }
57 
test_old_write_view()58 void test_old_write_view()
59 {
60     targa_write_view(
61         targa_out + "old_write_view_test.tga",
62         create_mandel_view(124, 124, gil::rgb8_pixel_t(0, 0, 255), gil::rgb8_pixel_t(0, 255, 0)));
63 }
64 
test_old_dynamic_image()65 void test_old_dynamic_image()
66 {
67     using my_img_types = mp11::mp_list
68     <
69         gil::gray8_image_t,
70         gil::gray16_image_t,
71         gil::rgb8_image_t,
72         gil::rgba8_image_t
73     >;
74 
75     gil::any_image<my_img_types> image;
76     gil::targa_read_image(targa_filename.c_str(), image);
77 
78     targa_write_view(targa_out + "old_dynamic_image_test.tga", gil::view(image));
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