mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +00:00
LibGfx/TIFF: Add support for tiled images
A tile is basically a strip with a user-defined width. With that in mind, adding support for them is quite straightforward. As a lot the common code was named after 'strips', to avoid future confusion I renamed everything that interact with either strips or tiles to a global term: 'segment'. Note that tiled images are supposed to always have a 'TileOffsets' tag instead of 'StripOffset'. However, this doesn't seem to be enforced by encoders, so we support having either of them indifferently. The test case was generated with the following Python script: import pyvips img = pyvips.Image.new_from_file('deflate.tiff') img.write_to_file('tiled.tiff', compression=pyvips.ForeignTiffCompression.DEFLATE, tile=True, tile_width=64, tile_height=64)
This commit is contained in:
parent
a30515011a
commit
8e21bbf7bf
3 changed files with 57 additions and 30 deletions
|
@ -776,6 +776,18 @@ TEST_CASE(test_tiff_cmyk)
|
|||
EXPECT_NE(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::White);
|
||||
}
|
||||
|
||||
TEST_CASE(test_tiff_tiled)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/tiled.tiff"sv)));
|
||||
EXPECT(Gfx::TIFFImageDecoderPlugin::sniff(file->bytes()));
|
||||
auto plugin_decoder = TRY_OR_FAIL(Gfx::TIFFImageDecoderPlugin::create(file->bytes()));
|
||||
|
||||
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 400, 300 }));
|
||||
|
||||
EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color::NamedColor::White);
|
||||
EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Red);
|
||||
}
|
||||
|
||||
TEST_CASE(test_tiff_invalid_tag)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/invalid_tag.tiff"sv)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue