Skip to content

Commit

Permalink
Add test for gray alpha based on tRNS chunk
Browse files Browse the repository at this point in the history
Add grayalpha-with-tRNS-chunk.png sourced from
https://css-ig.net/articles/truepng
for which the following call returns non-Zero value:

  png_get_valid( this->get_struct(), this->get_info(), PNG_INFO_tRNS )

Let's assume this is valid test image with tRNS chunk.

Add <define>BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES to Jamfile for PNG tests.
NOTE: Deliberately not defined BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
as it seems to require some extra configuration, currently it causes
some tests to fail. So, Jamfile likely needs more updates and clean-up.
  • Loading branch information
mloskot committed Jul 16, 2019
1 parent d7884ee commit 8d6d783
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/extension/io/Jamfile
Expand Up @@ -52,6 +52,7 @@ alias full :
:
:
:
<define>BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
[ ac.check-library /zlib//zlib : <library>/zlib//zlib : <build>no ]
[ ac.check-library /libpng//libpng : <library>/libpng//libpng : <build>no ]
]
Expand Down
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions test/extension/io/png_read_test.cpp
Expand Up @@ -125,6 +125,25 @@ BOOST_AUTO_TEST_CASE( read_pixel_per_meter )
BOOST_CHECK_EQUAL( backend._info._pixels_per_meter, png_uint_32( 1417 ));
}

BOOST_AUTO_TEST_CASE(read_grayscale_with_trns_chunk)
{
// Source of test image: bird-graylevel-a1.png at https://css-ig.net/articles/truepng
auto test_image = png_base_in + "grayscale-with-tRNS-chunk.png";
image_read_settings<png_tag> settings;
settings.set_read_members_true();

auto backend = read_image_info(test_image, settings);
BOOST_CHECK_EQUAL(backend._info._width, 200u);
BOOST_CHECK_EQUAL(backend._info._height, 193u);
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_GRAY);

gray_alpha8_image_t image;
read_image(test_image, image, settings);
BOOST_CHECK_EQUAL(image.width(), 200u);
BOOST_CHECK_EQUAL(image.height(), 193u);
}
#endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES

#ifdef BOOST_GIL_IO_USE_PNG_TEST_SUITE_IMAGES
Expand Down

0 comments on commit 8d6d783

Please sign in to comment.