• 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 all_formats_test
9 #include <boost/gil/extension/io/png.hpp>
10 #include <boost/gil/extension/io/bmp.hpp>
11 #include <boost/gil/extension/io/jpeg.hpp>
12 #include <boost/gil/extension/io/pnm.hpp>
13 #include <boost/gil/extension/io/targa.hpp>
14 #include <boost/gil/extension/io/tiff.hpp>
15 
16 #include <boost/test/unit_test.hpp>
17 
18 #include "paths.hpp"
19 
20 // Test will include all format's headers and load and write some images.
21 // This test is more of a compilation test.
22 
23 using namespace std;
24 using namespace boost::gil;
25 namespace fs = boost::filesystem;
26 
27 BOOST_AUTO_TEST_SUITE( gil_io_tests )
28 
BOOST_AUTO_TEST_CASE(non_bit_aligned_image_test)29 BOOST_AUTO_TEST_CASE( non_bit_aligned_image_test )
30 {
31 #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
32     {
33         rgb8_image_t img;
34         read_image( bmp_filename, img, bmp_tag() );
35 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
36 	fs::create_directories(fs::path(bmp_out));
37         write_view( bmp_out + "all_formats_test.bmp", view( img ), bmp_tag() );
38 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
39     }
40 
41     {
42         rgb8_image_t img;
43         read_image( jpeg_filename, img, jpeg_tag() );
44 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
45 	fs::create_directories(fs::path(jpeg_out));
46         write_view( jpeg_out + "all_formats_test.jpg", view( img ), jpeg_tag() );
47 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
48     }
49 
50     {
51         rgba8_image_t img;
52         read_image( png_filename, img, png_tag() );
53 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
54 	fs::create_directories(fs::path(png_out));
55         write_view( png_out + "all_formats_test.png", view( img ), png_tag() );
56 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
57     }
58 
59     {
60         rgb8_image_t img;
61         read_image( pnm_filename, img, pnm_tag() );
62 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
63 	fs::create_directories(fs::path(pnm_out));
64         write_view( pnm_out + "all_formats_test.pnm", view( img ), pnm_tag() );
65 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
66     }
67 
68     {
69         rgb8_image_t img;
70         read_image( targa_filename, img, targa_tag() );
71 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
72 	fs::create_directories(fs::path(targa_out));
73         write_view( targa_out + "all_formats_test.tga", view( img ), targa_tag() );
74 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
75     }
76 
77     {
78         rgba8_image_t img;
79         read_image( tiff_filename, img, tiff_tag() );
80 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
81 	fs::create_directories(fs::path(tiff_out));
82         write_view( tiff_out + "all_formats_test.tif", view( img ), tiff_tag() );
83 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
84     }
85 #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
86 }
87 
88 BOOST_AUTO_TEST_SUITE_END()
89