2 // Copyright 2013 Christian Henning
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
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
13 #include <boost/gil/extension/io/png.hpp>
15 #include <boost/test/unit_test.hpp>
20 using namespace boost::gil;
21 namespace fs = boost::filesystem;
23 using tag_t = png_tag;
25 BOOST_AUTO_TEST_SUITE( gil_io_png_tests )
27 #ifdef BOOST_GIL_IO_USE_PNG_TEST_SUITE_IMAGES
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
33 // The file name structure is as followed:
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)
43 BOOST_AUTO_TEST_CASE( file_format_test )
45 string in ( png_in + "PngSuite\\" );
47 fs::path in_path = fs::system_complete( fs::path( in ));
49 if ( fs::is_directory( in_path ) )
51 fs::directory_iterator end_iter;
52 for( fs::directory_iterator dir_itr( in_path )
57 if ( fs::is_regular( dir_itr->status() )
58 && ( fs::extension( dir_itr->path() ) == ".PNG" ))
61 string filename = in + dir_itr->path().leaf().string();
62 read_and_convert_image( filename, img, tag_t() );
64 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
65 write_view( png_out + fs::basename( dir_itr->path() ) + ".png"
69 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
75 #endif // BOOST_GIL_IO_USE_PNG_TEST_SUITE_IMAGES
77 BOOST_AUTO_TEST_SUITE_END()