mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 02:55:49 +03:00
LibGfx/TIFF: Apply the HorizontalDifferencing on the alpha channel
When present, the alpha channel is also affected by the horizontal differencing predictor. The test case was generated with GIMP with the following steps: - Open an RGB image - Add a transparency layer - Export as TIFF with the LZW compression scheme
This commit is contained in:
parent
0e6d87fe83
commit
1faf9bb44f
Notes:
sideshowbarker
2024-07-16 18:03:21 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/1faf9bb44f Pull-request: https://github.com/SerenityOS/serenity/pull/22908 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/nico ✅
@ -676,6 +676,18 @@ TEST_CASE(test_tiff_palette_alpha)
|
||||
EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Red);
|
||||
}
|
||||
|
||||
TEST_CASE(test_tiff_alpha_predictor)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/alpha_predictor.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).alpha(), 255);
|
||||
EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Red);
|
||||
}
|
||||
|
||||
TEST_CASE(test_tiff_16_bits)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/16_bits.tiff"sv)));
|
||||
|
BIN
Tests/LibGfx/test-inputs/tiff/alpha_predictor.tiff
Normal file
BIN
Tests/LibGfx/test-inputs/tiff/alpha_predictor.tiff
Normal file
Binary file not shown.
@ -267,6 +267,8 @@ private:
|
||||
color.set_red(last_color->red() + color.red());
|
||||
color.set_green(last_color->green() + color.green());
|
||||
color.set_blue(last_color->blue() + color.blue());
|
||||
if (alpha_channel_index().has_value())
|
||||
color.set_alpha(last_color->alpha() + color.alpha());
|
||||
}
|
||||
|
||||
last_color = color;
|
||||
|
Loading…
Reference in New Issue
Block a user