mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
LibGfx: Set correct alpha type for webp decoding
The libwebp decoder gives us unpremultiplied color data, so mark our bitmaps as such.
This commit is contained in:
parent
07300a5bb4
commit
768d814ffd
Notes:
github-actions[bot]
2024-10-02 20:04:31 +00:00
Author: https://github.com/gmta
Commit: 768d814ffd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1598
3 changed files with 15 additions and 2 deletions
|
@ -927,6 +927,19 @@ TEST_CASE(test_webp_extended_lossless_animated)
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE(test_webp_unpremultiplied_alpha)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("webp/semi-transparent-pixel.webp"sv)));
|
||||
EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes()));
|
||||
auto plugin_decoder = TRY_OR_FAIL(Gfx::WebPImageDecoderPlugin::create(file->bytes()));
|
||||
|
||||
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 1, 1 }));
|
||||
|
||||
// Webp decodes with unpremultiplied color data, so {R,G,B} can be >A (unlike with premultiplied colors).
|
||||
EXPECT_EQ(frame.image->alpha_type(), Gfx::AlphaType::Unpremultiplied);
|
||||
EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color(255, 255, 255, 128));
|
||||
}
|
||||
|
||||
TEST_CASE(test_tvg)
|
||||
{
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tvg/yak.tvg"sv)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue