1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:48:11 +00:00

LibGfx/TIFF: Modify the image according to the Orientation tag

Let's use the already existing logic (ExifOrientedBitmap) to modify the
bitmap to honor the orientation tag.
This commit is contained in:
Lucas CHOLLET 2024-01-07 00:20:40 -05:00 committed by Andreas Kling
parent 367882ae23
commit 335097e446
3 changed files with 20 additions and 4 deletions

View file

@ -546,6 +546,19 @@ TEST_CASE(test_tiff_deflate)
EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Red);
}
TEST_CASE(test_tiff_orientation)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("tiff/orientation.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, { 300, 400 }));
// Orientation is Rotate90Clockwise
EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color::NamedColor::White);
EXPECT_EQ(frame.image->get_pixel(300 - 75, 60), Gfx::Color::NamedColor::Red);
}
TEST_CASE(test_tiff_packed_bits)
{
auto file = MUST(Core::MappedFile::map(TEST_INPUT("tiff/packed_bits.tiff"sv)));