123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731 |
- //
- // Copyright 2013 Christian Henning
- //
- // Distributed under the Boost Software License, Version 1.0
- // See accompanying file LICENSE_1_0.txt or copy at
- // http://www.boost.org/LICENSE_1_0.txt
- //
- //#define BOOST_TEST_MODULE png_read_test_module
- #define BOOST_GIL_IO_ADD_FS_PATH_SUPPORT
- #define BOOST_GIL_IO_ENABLE_GRAY_ALPHA
- #define BOOST_FILESYSTEM_VERSION 3
- #include <boost/gil/extension/io/png.hpp>
- #include <boost/test/unit_test.hpp>
- #include <cstdint>
- #include <iostream>
- #include "paths.hpp"
- #include "scanline_read_test.hpp"
- #include "unit_test_utility.hpp"
- using namespace std;
- using namespace boost;
- using namespace gil;
- using namespace boost::gil::detail;
- namespace fs = boost::filesystem;
- using tag_t = png_tag;
- BOOST_AUTO_TEST_SUITE( gil_io_png_tests )
- using gray_alpha8_pixel_t = pixel<uint8_t, gray_alpha_layout_t>;
- using gray_alpha8_image_t= image<gray_alpha8_pixel_t, false>;
- using gray_alpha16_pixel_t = pixel<uint16_t, gray_alpha_layout_t>;
- using gray_alpha16_image_t = image<gray_alpha16_pixel_t, false>;
- template< typename Image >
- void test_file( string filename )
- {
- Image src, dst;
- image_read_settings< png_tag > settings;
- settings._read_file_gamma = true;
- settings._read_transparency_data = true;
- using backend_t = get_reader_backend<std::string const, tag_t>::type;
- backend_t backend = read_image_info( png_in + filename
- , settings
- );
- read_image( png_in + filename
- , src
- , settings
- );
- #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
- image_write_info< png_tag > write_info;
- write_info._file_gamma = backend._info._file_gamma;
- write_view( png_out + filename
- , view( src )
- , write_info
- );
- read_image( png_out + filename
- , dst
- , settings
- );
- BOOST_CHECK( equal_pixels( const_view( src )
- , const_view( dst )
- )
- );
- #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
- }
- template< typename Image >
- void test_png_scanline_reader( string filename )
- {
- test_scanline_reader<Image, png_tag>( string( png_in + filename ).c_str() );
- }
- BOOST_AUTO_TEST_CASE( read_header_test )
- {
- using backend_t = get_reader_backend<std::string const, tag_t>::type;
- backend_t backend = read_image_info( png_filename
- , tag_t()
- );
- BOOST_CHECK_EQUAL( backend._info._width , 1000u );
- BOOST_CHECK_EQUAL( backend._info._height, 600u );
- BOOST_CHECK_EQUAL( backend._info._num_channels, 4 );
- BOOST_CHECK_EQUAL( backend._info._bit_depth , 8 );
- BOOST_CHECK_EQUAL( backend._info._color_type , PNG_COLOR_TYPE_RGBA );
- BOOST_CHECK_EQUAL( backend._info._interlace_method , PNG_INTERLACE_NONE );
- BOOST_CHECK_EQUAL( backend._info._compression_method, PNG_COMPRESSION_TYPE_BASE );
- BOOST_CHECK_EQUAL( backend._info._filter_method , PNG_FILTER_TYPE_BASE );
- BOOST_CHECK_EQUAL( backend._info._file_gamma, 1 );
- }
- #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
- BOOST_AUTO_TEST_CASE( read_pixel_per_meter )
- {
- image_read_settings< png_tag > settings;
- settings.set_read_members_true();
- using backend_t = get_reader_backend<std::string const, tag_t>::type;
- backend_t backend = read_image_info( png_base_in + "EddDawson/36dpi.png"
- , settings
- );
- BOOST_CHECK_EQUAL( backend._info._pixels_per_meter, png_uint_32( 1417 ));
- }
- BOOST_AUTO_TEST_CASE(read_with_trns_chunk_color_type_0)
- {
- // PNG 1.2: For color type 0 (grayscale), the tRNS chunk contains a single gray level value,
- // stored in the format:
- //
- // Gray: 2 bytes, range 0 .. (2^bitdepth)-1
- {
- auto const png_path = png_in + "tbbn0g04.png";
- image_read_settings<png_tag> settings;
- settings.set_read_members_true();
- auto backend = read_image_info(png_path, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_CHECK_EQUAL(backend._info._bit_depth, 4);
- BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
- BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_GRAY);
- gray_alpha8_image_t img;
- read_image(png_path, img, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_TEST(const_view(img).front() == gray_alpha8c_pixel_t(255, 0));
- BOOST_TEST(const_view(img)[78] == gray_alpha8c_pixel_t(221, 255));
- BOOST_TEST(const_view(img)[79] == gray_alpha8c_pixel_t(204, 255));
- BOOST_TEST(const_view(img)[975] == gray_alpha8c_pixel_t(238, 255));
- BOOST_TEST(const_view(img)[976] == gray_alpha8c_pixel_t(221, 255));
- BOOST_TEST(const_view(img).back() == gray_alpha8c_pixel_t(255, 0));
- }
- {
- auto const png_path = png_in + "tbwn0g16.png";
- image_read_settings<png_tag> settings;
- settings.set_read_members_true();
- auto backend = read_image_info(png_path, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_CHECK_EQUAL(backend._info._bit_depth, 16);
- BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
- BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_GRAY);
- gray_alpha16_image_t img;
- read_image(png_path, img, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_TEST(const_view(img).front() == gray_alpha16c_pixel_t(65535, 0));
- BOOST_TEST(const_view(img)[78] == gray_alpha16c_pixel_t(58339, 65535));
- BOOST_TEST(const_view(img)[79] == gray_alpha16c_pixel_t(51657, 65535));
- BOOST_TEST(const_view(img)[975] == gray_alpha16c_pixel_t(62965, 65535));
- BOOST_TEST(const_view(img)[976] == gray_alpha16c_pixel_t(58339, 65535));
- BOOST_TEST(const_view(img).back() == gray_alpha16c_pixel_t(65535, 0));
- }
- }
- BOOST_AUTO_TEST_CASE(read_with_trns_chunk_color_type_2)
- {
- // PNG 1.2: For color type 2 (truecolor), the tRNS chunk contains a single RGB color value,
- // stored in the format:
- //
- // Red: 2 bytes, range 0 .. (2^bitdepth)-1
- // Green: 2 bytes, range 0 .. (2^bitdepth)-1
- // Blue: 2 bytes, range 0 .. (2^bitdepth)-1
- {
- auto const png_path = png_in + "tbbn2c16.png";
- image_read_settings<png_tag> settings;
- settings.set_read_members_true();
- auto backend = read_image_info(png_path, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_CHECK_EQUAL(backend._info._bit_depth, 16);
- BOOST_CHECK_EQUAL(backend._info._num_channels, 3u);
- BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_RGB);
- rgba16_image_t img;
- read_image(png_path, img, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_TEST(const_view(img).front() == rgba16c_pixel_t(65535, 65535, 65535, 0));
- BOOST_TEST(const_view(img)[78] == rgba16c_pixel_t(58339, 58339, 58339, 65535));
- BOOST_TEST(const_view(img)[79] == rgba16c_pixel_t(51657, 51657, 51657, 65535));
- BOOST_TEST(const_view(img)[975] == rgba16c_pixel_t(62965, 62965, 62965, 65535));
- BOOST_TEST(const_view(img)[976] == rgba16c_pixel_t(58339, 58339, 58339, 65535));
- BOOST_TEST(const_view(img).back() == rgba16c_pixel_t(65535, 65535, 65535, 0));
- }
- {
- auto const png_path = png_in + "tbgn2c16.png";
- image_read_settings<png_tag> settings;
- settings.set_read_members_true();
- auto backend = read_image_info(png_path, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_CHECK_EQUAL(backend._info._bit_depth, 16);
- BOOST_CHECK_EQUAL(backend._info._num_channels, 3u);
- BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_RGB);
- rgba16_image_t img;
- read_image(png_path, img, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_TEST(const_view(img).front() == rgba16c_pixel_t(65535, 65535, 65535, 0));
- BOOST_TEST(const_view(img)[78] == rgba16c_pixel_t(58339, 58339, 58339, 65535));
- BOOST_TEST(const_view(img)[79] == rgba16c_pixel_t(51657, 51657, 51657, 65535));
- BOOST_TEST(const_view(img)[975] == rgba16c_pixel_t(62965, 62965, 62965, 65535));
- BOOST_TEST(const_view(img)[976] == rgba16c_pixel_t(58339, 58339, 58339, 65535));
- BOOST_TEST(const_view(img).back() == rgba16c_pixel_t(65535, 65535, 65535, 0));
- }
- {
- auto const png_path = png_in + "tbrn2c08.png";
- image_read_settings<png_tag> settings;
- settings.set_read_members_true();
- auto backend = read_image_info(png_path, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_CHECK_EQUAL(backend._info._bit_depth, 8);
- BOOST_CHECK_EQUAL(backend._info._num_channels, 3u);
- BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_RGB);
- rgba8_image_t img;
- read_image(png_path, img, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_TEST(const_view(img).front() == rgba8c_pixel_t(255, 255, 255, 0));
- BOOST_TEST(const_view(img)[78] == rgba8c_pixel_t(227, 227, 227, 255));
- BOOST_TEST(const_view(img)[79] == rgba8c_pixel_t(201, 201, 201, 255));
- BOOST_TEST(const_view(img)[975] == rgba8c_pixel_t(245, 245, 245, 255));
- BOOST_TEST(const_view(img)[976] == rgba8c_pixel_t(227, 227, 227, 255));
- BOOST_TEST(const_view(img).back() == rgba8c_pixel_t(255, 255, 255, 0));
- }
- }
- BOOST_AUTO_TEST_CASE(read_with_trns_chunk_color_type_3)
- {
- // PNG 1.2: For color type 3 (indexed color), the tRNS chunk contains a series of one-byte
- // alpha values, corresponding to entries in the PLTE chunk:
- //
- // Alpha for palette index 0: 1 byte
- // Alpha for palette index 1: 1 byte
- // ...etc...
- {
- auto const png_path = png_in + "tbbn3p08.png";
- image_read_settings<png_tag> settings;
- settings.set_read_members_true();
- auto backend = read_image_info(png_path, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_CHECK_EQUAL(backend._info._bit_depth, 8);
- BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
- BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_PALETTE);
- rgba8_image_t img;
- read_image(png_path, img, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_TEST(const_view(img).front() == rgba8c_pixel_t(255, 255, 255, 0));
- BOOST_TEST(const_view(img)[78] == rgba8c_pixel_t(227, 227, 227, 255));
- BOOST_TEST(const_view(img)[79] == rgba8c_pixel_t(201, 201, 201, 255));
- BOOST_TEST(const_view(img)[975] == rgba8c_pixel_t(246, 246, 246, 255));
- BOOST_TEST(const_view(img)[976] == rgba8c_pixel_t(227, 227, 227, 255));
- BOOST_TEST(const_view(img).back() == rgba8c_pixel_t(255, 255, 255, 0));
- }
- {
- auto const png_path = png_in + "tbgn3p08.png";
- image_read_settings<png_tag> settings;
- settings.set_read_members_true();
- auto backend = read_image_info(png_path, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_CHECK_EQUAL(backend._info._bit_depth, 8);
- BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
- BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_PALETTE);
- rgba8_image_t img;
- read_image(png_path, img, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_TEST(const_view(img).front() == rgba8c_pixel_t(255, 255, 255, 0));
- BOOST_TEST(const_view(img)[78] == rgba8c_pixel_t(227, 227, 227, 255));
- BOOST_TEST(const_view(img)[79] == rgba8c_pixel_t(201, 201, 201, 255));
- BOOST_TEST(const_view(img)[975] == rgba8c_pixel_t(246, 246, 246, 255));
- BOOST_TEST(const_view(img)[976] == rgba8c_pixel_t(227, 227, 227, 255));
- BOOST_TEST(const_view(img).back() == rgba8c_pixel_t(255, 255, 255, 0));
- }
- {
- auto const png_path = png_in + "tp1n3p08.png";
- image_read_settings<png_tag> settings;
- settings.set_read_members_true();
- auto backend = read_image_info(png_path, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_CHECK_EQUAL(backend._info._bit_depth, 8);
- BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
- BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_PALETTE);
- rgba8_image_t img;
- read_image(png_path, img, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_TEST(const_view(img).front() == rgba8c_pixel_t(255, 255, 255, 0));
- BOOST_TEST(const_view(img)[78] == rgba8c_pixel_t(227, 227, 227, 255));
- BOOST_TEST(const_view(img)[79] == rgba8c_pixel_t(201, 201, 201, 255));
- BOOST_TEST(const_view(img)[975] == rgba8c_pixel_t(246, 246, 246, 255));
- BOOST_TEST(const_view(img)[976] == rgba8c_pixel_t(227, 227, 227, 255));
- BOOST_TEST(const_view(img).back() == rgba8c_pixel_t(255, 255, 255, 0));
- }
- {
- auto const png_path = png_in + "tm3n3p02.png";
- image_read_settings<png_tag> settings;
- settings.set_read_members_true();
- auto backend = read_image_info(png_path, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_CHECK_EQUAL(backend._info._bit_depth, 2);
- BOOST_CHECK_EQUAL(backend._info._num_channels, 1u);
- BOOST_CHECK_EQUAL(backend._info._color_type, PNG_COLOR_TYPE_PALETTE);
- rgba8_image_t img;
- read_image(png_path, img, settings);
- BOOST_CHECK_EQUAL(backend._info._width, 32u);
- BOOST_CHECK_EQUAL(backend._info._height, 32u);
- BOOST_TEST(const_view(img).front() == rgba8c_pixel_t(0, 0, 255, 0));
- BOOST_TEST(const_view(img)[16] == rgba8c_pixel_t(0, 0, 255, 85));
- BOOST_TEST(const_view(img)[511] == rgba8c_pixel_t(0, 0, 255, 85));
- BOOST_TEST(const_view(img)[1007] == rgba8c_pixel_t(0, 0, 255, 170));
- BOOST_TEST(const_view(img).back() == rgba8c_pixel_t(0, 0, 255, 255));
- }
- }
- #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
- #ifdef BOOST_GIL_IO_USE_PNG_TEST_SUITE_IMAGES
- BOOST_AUTO_TEST_CASE( BASIc_format_test )
- {
- // Basic format test files (non-interlaced)
- // BASN0g01 - black & white
- test_file< gray1_image_t >( "BASN0G01.PNG" );
- test_png_scanline_reader< gray1_image_t >( "BASN0G01.PNG" );
- // BASN0g02 - 2 bit (4 level) grayscale
- test_file< gray2_image_t >( "BASN0G02.PNG" );
- test_png_scanline_reader< gray2_image_t >( "BASN0G02.PNG" );
- // BASN0g04 - 4 bit (16 level) grayscale
- test_file< gray4_image_t >( "BASN0G04.PNG" );
- test_png_scanline_reader< gray4_image_t >( "BASN0G04.PNG" );
- // BASN0g08 - 8 bit (256 level) grayscale
- test_file< gray8_image_t >( "BASN0G08.PNG" );
- test_png_scanline_reader< gray8_image_t >( "BASN0G08.PNG" );
- // BASN0g16 - 16 bit (64k level) grayscale
- test_file< gray16_image_t >( "BASN0G16.PNG" );
- test_png_scanline_reader< gray16_image_t >( "BASN0G16.PNG" );
- // BASN2c08 - 3x8 bits rgb color
- test_file< rgb8_image_t >( "BASN2C08.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "BASN2C08.PNG" );
- // BASN2c16 - 3x16 bits rgb color
- test_file< rgb16_image_t >( "BASN2C16.PNG" );
- test_png_scanline_reader< rgb16_image_t >( "BASN2C16.PNG" );
- // BASN3p01 - 1 bit (2 color) paletted
- test_file< rgb8_image_t >( "BASN3P01.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "BASN3P01.PNG" );
- // BASN3p02 - 2 bit (4 color) paletted
- test_file< rgb8_image_t >( "BASN3P02.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "BASN3P02.PNG" );
- // BASN3p04 - 4 bit (16 color) paletted
- test_file< rgb8_image_t >( "BASN3P04.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "BASN3P04.PNG" );
- // BASN3p08 - 8 bit (256 color) paletted
- test_file< rgb8_image_t >( "BASN3P08.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "BASN3P08.PNG" );
- // BASN4a08 - 8 bit grayscale + 8 bit alpha-channel
- test_file< gray_alpha8_image_t >( "BASN4A08.PNG" );
- test_png_scanline_reader< gray_alpha8_image_t >( "BASN4A08.PNG" );
- // BASN4a16 - 16 bit grayscale + 16 bit alpha-channel
- test_file< gray_alpha16_image_t >( "BASN4A16.PNG" );
- test_png_scanline_reader< gray_alpha16_image_t >( "BASN4A16.PNG" );
- // BASN6a08 - 3x8 bits rgb color + 8 bit alpha-channel
- test_file< rgba8_image_t >( "BASN6A08.PNG" );
- test_png_scanline_reader< rgba8_image_t >( "BASN6A08.PNG" );
- // BASN6a16 - 3x16 bits rgb color + 16 bit alpha-channel
- test_file< rgba16_image_t >( "BASN6A16.PNG" );
- test_png_scanline_reader< rgba16_image_t >( "BASN6A16.PNG" );
- }
- BOOST_AUTO_TEST_CASE( BASIc_format_interlaced_test )
- {
- // Basic format test files (Adam-7 interlaced)
- // BASI0g01 - black & white
- test_file< gray1_image_t >( "BASI0G01.PNG" );
- // BASI0g02 - 2 bit (4 level) grayscale
- test_file< gray2_image_t >( "BASI0G02.PNG" );
- // BASI0g04 - 4 bit (16 level) grayscale
- test_file< gray4_image_t >( "BASI0G04.PNG" );
- // BASI0g08 - 8 bit (256 level) grayscale
- test_file< gray8_image_t >( "BASI0G08.PNG" );
- // BASI0g16 - 16 bit (64k level) grayscale
- test_file< gray16_image_t >( "BASI0G16.PNG" );
- // BASI2c08 - 3x8 bits rgb color
- test_file< rgb8_image_t >( "BASI2C08.PNG" );
- // BASI2c16 - 3x16 bits rgb color
- test_file< rgb16_image_t >( "BASI2C16.PNG" );
- // BASI3p01 - 1 bit (2 color) paletted
- test_file< rgb8_image_t >( "BASI3P01.PNG" );
- // BASI3p02 - 2 bit (4 color) paletted
- test_file< rgb8_image_t >( "BASI3P02.PNG" );
- // BASI3p04 - 4 bit (16 color) paletted
- test_file< rgb8_image_t >( "BASI3P04.PNG" );
- // BASI3p08 - 8 bit (256 color) paletted
- test_file< rgb8_image_t >( "BASI3P08.PNG" );
- // BASI4a08 - 8 bit grayscale + 8 bit alpha-channel
- test_file< gray_alpha8_image_t >( "BASI4A08.PNG" );
- // BASI4a16 - 16 bit grayscale + 16 bit alpha-channel
- test_file< gray_alpha16_image_t >( "BASI4A16.PNG" );
- // BASI6a08 - 3x8 bits rgb color + 8 bit alpha-channel
- test_file< rgba8_image_t >( "BASI6A08.PNG" );
- // BASI6a16 - 3x16 bits rgb color + 16 bit alpha-channel
- test_file< rgba16_image_t >( "BASI6A16.PNG" );
- }
- BOOST_AUTO_TEST_CASE( odd_sizes_test )
- {
- // S01I3P01 - 1x1 paletted file, interlaced
- test_file< rgb8_image_t >( "S01I3P01.PNG" );
- // S01N3P01 - 1x1 paletted file, no interlacing
- test_file< rgb8_image_t >( "S01N3P01.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S01N3P01.PNG" );
- // S02I3P01 - 2x2 paletted file, interlaced
- test_file< rgb8_image_t >( "S02I3P01.PNG" );
- // S02N3P01 - 2x2 paletted file, no interlacing
- test_file< rgb8_image_t >( "S02N3P01.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S02N3P01.PNG" );
- // S03I3P01 - 3x3 paletted file, interlaced
- test_file< rgb8_image_t >( "S03I3P01.PNG" );
- // S03N3P01 - 3x3 paletted file, no interlacing
- test_file< rgb8_image_t >( "S03N3P01.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S03N3P01.PNG" );
- // S04I3P01 - 4x4 paletted file, interlaced
- test_file< rgb8_image_t >( "S04I3P01.PNG" );
- // S04N3P01 - 4x4 paletted file, no interlacing
- test_file< rgb8_image_t >( "S04N3P01.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S04N3P01.PNG" );
- // S05I3P02 - 5x5 paletted file, interlaced
- test_file< rgb8_image_t >( "S05I3P02.PNG" );
- // S05N3P02 - 5x5 paletted file, no interlacing
- test_file< rgb8_image_t >( "S05N3P02.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S05N3P02.PNG" );
- // S06I3P02 - 6x6 paletted file, interlaced
- test_file< rgb8_image_t >( "S06I3P02.PNG" );
- // S06N3P02 - 6x6 paletted file, no interlacing
- test_file< rgb8_image_t >( "S06N3P02.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S06N3P02.PNG" );
- // S07I3P02 - 7x7 paletted file, interlaced
- test_file< rgb8_image_t >( "S07I3P02.PNG" );
- // S07N3P02 - 7x7 paletted file, no interlacing
- test_file< rgb8_image_t >( "S07N3P02.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S07N3P02.PNG" );
- // S08I3P02 - 8x8 paletted file, interlaced
- test_file< rgb8_image_t >( "S08I3P02.PNG" );
- // S08N3P02 - 8x8 paletted file, no interlacing
- test_file< rgb8_image_t >( "S08N3P02.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S08N3P02.PNG" );
- // S09I3P02 - 9x9 paletted file, interlaced
- test_file< rgb8_image_t >( "S09I3P02.PNG" );
- // S09N3P02 - 9x9 paletted file, no interlacing
- test_file< rgb8_image_t >( "S09N3P02.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S09N3P02.PNG" );
- // S32I3P04 - 32x32 paletted file, interlaced
- test_file< rgb8_image_t >( "S32I3P04.PNG" );
- // S32N3P04 - 32x32 paletted file, no interlacing
- test_file< rgb8_image_t >( "S32N3P04.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S32N3P04.PNG" );
- // S33I3P04 - 33x33 paletted file, interlaced
- test_file< rgb8_image_t >( "S33I3P04.PNG" );
- // S33N3P04 - 33x33 paletted file, no interlacing
- test_file< rgb8_image_t >( "S33N3P04.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S33N3P04.PNG" );
- // S34I3P04 - 34x34 paletted file, interlaced
- test_file< rgb8_image_t >( "S34I3P04.PNG" );
- // S34N3P04 - 34x34 paletted file, no interlacing
- test_file< rgb8_image_t >( "S34N3P04.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S34N3P04.PNG" );
- // S35I3P04 - 35x35 paletted file, interlaced
- test_file< rgb8_image_t >( "S35I3P04.PNG" );
- // S35N3P04 - 35x35 paletted file, no interlacing
- test_file< rgb8_image_t >( "S35N3P04.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S35N3P04.PNG" );
- // S36I3P04 - 36x36 paletted file, interlaced
- test_file< rgb8_image_t >( "S36I3P04.PNG" );
- // S36N3P04 - 36x36 paletted file, no interlacing
- test_file< rgb8_image_t >( "S36N3P04.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S36N3P04.PNG" );
- // S37I3P04 - 37x37 paletted file, interlaced
- test_file< rgb8_image_t >( "S37I3P04.PNG" );
- // S37N3P04 - 37x37 paletted file, no interlacing
- test_file< rgb8_image_t >( "S37N3P04.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S37N3P04.PNG" );
- // S38I3P04 - 38x38 paletted file, interlaced
- test_file< rgb8_image_t >( "S38I3P04.PNG" );
- // S38N3P04 - 38x38 paletted file, no interlacing
- test_file< rgb8_image_t >( "S38N3P04.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S38N3P04.PNG" );
- // S39I3P04 - 39x39 paletted file, interlaced
- test_file< rgb8_image_t >( "S39I3P04.PNG" );
- // S39N3P04 - 39x39 paletted file, no interlacing
- test_file< rgb8_image_t >( "S39N3P04.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S39N3P04.PNG" );
- // S40I3P04 - 40x40 paletted file, interlaced
- test_file< rgb8_image_t >( "S40I3P04.PNG" );
- // S40N3P04 - 40x40 paletted file, no interlacing
- test_file< rgb8_image_t >( "S40N3P04.PNG" );
- test_png_scanline_reader< rgb8_image_t >( "S40N3P04.PNG" );
- }
- BOOST_AUTO_TEST_CASE( background_test )
- {
- // BGAI4A08 - 8 bit grayscale, alpha, no background chunk, interlaced
- test_file< gray_alpha8_image_t >( "BGAI4A08.PNG" );
- // BGAI4A16 - 16 bit grayscale, alpha, no background chunk, interlaced
- test_file< gray_alpha16_image_t >( "BGAI4A16.PNG" );
- // BGAN6A08 - 3x8 bits rgb color, alpha, no background chunk
- test_file< rgba8_image_t >( "BGAN6A08.PNG" );
- // BGAN6A16 - 3x16 bits rgb color, alpha, no background chunk
- test_file< rgba16_image_t >( "BGAN6A16.PNG" );
- // BGBN4A08 - 8 bit grayscale, alpha, black background chunk
- test_file< gray_alpha8_image_t >( "BGBN4A08.PNG" );
- // BGGN4A16 - 16 bit grayscale, alpha, gray background chunk
- test_file< gray_alpha16_image_t >( "BGGN4A16.PNG" );
- // BGWN6A08 - 3x8 bits rgb color, alpha, white background chunk
- test_file< rgba8_image_t >( "BGWN6A08.PNG" );
- // BGYN6A16 - 3x16 bits rgb color, alpha, yellow background chunk
- test_file< rgba16_image_t >( "BGYN6A16.PNG" );
- }
- BOOST_AUTO_TEST_CASE( transparency_test )
- {
- // TBBN1G04 - transparent, black background chunk
- // file missing
- //test_file< gray_alpha8_image_t >( "TBBN1G04.PNG" );
- // TBBN2C16 - transparent, blue background chunk
- test_file< rgba16_image_t >( "TBBN2C16.PNG" );
- // TBBN3P08 - transparent, black background chunk
- test_file< rgba8_image_t >( "TBBN3P08.PNG" );
- // TBGN2C16 - transparent, green background chunk
- test_file< rgba16_image_t >( "TBGN2C16.PNG" );
- // TBGN3P08 - transparent, light-gray background chunk
- test_file< rgba8_image_t >( "TBGN3P08.PNG" );
- // TBRN2C08 - transparent, red background chunk
- test_file< rgba8_image_t >( "TBRN2C08.PNG" );
- // TBWN1G16 - transparent, white background chunk
- test_file< gray_alpha16_image_t >( "TBWN0G16.PNG" );
- // TBWN3P08 - transparent, white background chunk
- test_file< rgba8_image_t >( "TBWN3P08.PNG" );
- // TBYN3P08 - transparent, yellow background chunk
- test_file< rgba8_image_t >( "TBYN3P08.PNG" );
- // TP0N1G08 - not transparent for reference (logo on gray)
- test_file< gray8_image_t >( "TP0N0G08.PNG" );
- // TP0N2C08 - not transparent for reference (logo on gray)
- test_file< rgb8_image_t >( "TP0N2C08.PNG" );
- // TP0N3P08 - not transparent for reference (logo on gray)
- test_file< rgb8_image_t >( "TP0N3P08.PNG" );
- // TP1N3P08 - transparent, but no background chunk
- test_file< rgba8_image_t >( "TP1N3P08.PNG" );
- }
- BOOST_AUTO_TEST_CASE( gamma_test )
- {
- // G03N0G16 - grayscale, file-gamma = 0.35
- test_file< gray16_image_t >( "G03N0G16.PNG" );
- // G03N2C08 - color, file-gamma = 0.35
- test_file< rgb8_image_t >( "G03N2C08.PNG" );
- // G03N3P04 - paletted, file-gamma = 0.35
- test_file< rgb8_image_t >( "G03N3P04.PNG" );
- // G04N0G16 - grayscale, file-gamma = 0.45
- test_file< gray16_image_t >( "G04N0G16.PNG" );
- // G04N2C08 - color, file-gamma = 0.45
- test_file< rgb8_image_t >( "G04N2C08.PNG" );
- // G04N3P04 - paletted, file-gamma = 0.45
- test_file< rgb8_image_t >( "G04N3P04.PNG" );
- // G05N0G16 - grayscale, file-gamma = 0.55
- test_file< gray16_image_t >( "G05N0G16.PNG" );
- // G05N2C08 - color, file-gamma = 0.55
- test_file< rgb8_image_t >( "G05N2C08.PNG" );
- // G05N3P04 - paletted, file-gamma = 0.55
- test_file< rgb8_image_t >( "G05N3P04.PNG" );
- // G07N0G16 - grayscale, file-gamma = 0.70
- test_file< gray16_image_t >( "G07N0G16.PNG" );
- // G07N2C08 - color, file-gamma = 0.70
- test_file< rgb8_image_t >( "G07N2C08.PNG" );
- // G07N3P04 - paletted, file-gamma = 0.70
- test_file< rgb8_image_t >( "G07N3P04.PNG" );
- // G10N0G16 - grayscale, file-gamma = 1.00
- test_file< gray16_image_t >( "G10N0G16.PNG" );
- // G10N2C08 - color, file-gamma = 1.00
- test_file< rgb8_image_t >( "G10N2C08.PNG" );
- // G10N3P04 - paletted, file-gamma = 1.00
- test_file< rgb8_image_t >( "G10N3P04.PNG" );
- // G25N0G16 - grayscale, file-gamma = 2.50
- test_file< gray16_image_t >( "G25N0G16.PNG" );
- // G25N2C08 - color, file-gamma = 2.50
- test_file< rgb8_image_t >( "G25N2C08.PNG" );
- // G25N3P04 - paletted, file-gamma = 2.50
- test_file< rgb8_image_t >( "G25N3P04.PNG" );
- }
- #endif // BOOST_GIL_IO_USE_PNG_TEST_SUITE_IMAGES
- BOOST_AUTO_TEST_SUITE_END()
|