]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
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 png_file_format_test_module | |
9 | #define BOOST_GIL_IO_ADD_FS_PATH_SUPPORT | |
10 | #define BOOST_GIL_IO_ENABLE_GRAY_ALPHA | |
11 | #define BOOST_FILESYSTEM_VERSION 3 | |
12 | ||
13 | #include <boost/gil/extension/io/png.hpp> | |
14 | ||
15 | #include <boost/test/unit_test.hpp> | |
16 | ||
17 | #include "paths.hpp" | |
18 | ||
19 | using namespace std; | |
20 | using namespace boost::gil; | |
21 | namespace fs = boost::filesystem; | |
22 | ||
23 | using tag_t = png_tag; | |
24 | ||
25 | BOOST_AUTO_TEST_SUITE( gil_io_png_tests ) | |
26 | ||
27 | #ifdef BOOST_GIL_IO_USE_PNG_TEST_SUITE_IMAGES | |
28 | ||
29 | // Test will loop through the "in" folder to read and convert | |
30 | // the png's to rgb8_image_t's. Which then will be written in | |
31 | // the "out" folder. | |
32 | // | |
33 | // The file name structure is as followed: | |
34 | // | |
35 | // g04i2c08.png | |
36 | // || |||+---- bit-depth | |
37 | // || ||+----- color-type (descriptive) | |
38 | // || |+------ color-type (numerical) | |
39 | // || +------- interlaced or non-interlaced | |
40 | // |+--------- parameter of test (in this case gamma-value) | |
41 | // +---------- test feature (in this case gamma) | |
42 | ||
43 | BOOST_AUTO_TEST_CASE( file_format_test ) | |
44 | { | |
45 | string in ( png_in + "PngSuite\\" ); | |
46 | ||
47 | fs::path in_path = fs::system_complete( fs::path( in )); | |
48 | ||
49 | if ( fs::is_directory( in_path ) ) | |
50 | { | |
51 | fs::directory_iterator end_iter; | |
52 | for( fs::directory_iterator dir_itr( in_path ) | |
53 | ; dir_itr != end_iter | |
54 | ; ++dir_itr | |
55 | ) | |
56 | { | |
57 | if ( fs::is_regular( dir_itr->status() ) | |
58 | && ( fs::extension( dir_itr->path() ) == ".PNG" )) | |
59 | { | |
60 | rgb8_image_t img; | |
61 | string filename = in + dir_itr->path().leaf().string(); | |
62 | read_and_convert_image( filename, img, tag_t() ); | |
63 | ||
64 | #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES | |
65 | write_view( png_out + fs::basename( dir_itr->path() ) + ".png" | |
66 | , view( img ) | |
67 | , png_tag() | |
68 | ); | |
69 | #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES | |
70 | } | |
71 | } | |
72 | } | |
73 | } | |
74 | ||
75 | #endif // BOOST_GIL_IO_USE_PNG_TEST_SUITE_IMAGES | |
76 | ||
77 | BOOST_AUTO_TEST_SUITE_END() |