mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
Tests: Add a test that triggers the webp color indexing saving path
This commit is contained in:
parent
47d3245ea7
commit
4a327d98a4
Notes:
sideshowbarker
2024-07-17 03:03:15 +09:00
Author: https://github.com/nico
Commit: 4a327d98a4
Pull-request: https://github.com/SerenityOS/serenity/pull/24483
Reviewed-by: https://github.com/gmta ✅
1 changed files with 21 additions and 0 deletions
|
@ -186,6 +186,27 @@ TEST_CASE(test_webp)
|
|||
TRY_OR_FAIL((test_roundtrip<Gfx::WebPWriter, Gfx::WebPImageDecoderPlugin>(TRY_OR_FAIL(create_test_rgba_bitmap()))));
|
||||
}
|
||||
|
||||
TEST_CASE(test_webp_color_indexing_transform)
|
||||
{
|
||||
Array<Color, 256> colors;
|
||||
for (size_t i = 0; i < colors.size(); ++i) {
|
||||
colors[i].set_red(i);
|
||||
colors[i].set_green(255 - i);
|
||||
colors[i].set_blue(128);
|
||||
colors[i].set_alpha(255 - i / 16);
|
||||
}
|
||||
for (int bits_per_pixel : { 1, 2, 4, 8 }) {
|
||||
int number_of_colors = 1 << bits_per_pixel;
|
||||
|
||||
auto bitmap = TRY_OR_FAIL(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, { 47, 33 }));
|
||||
for (int y = 0; y < bitmap->height(); ++y)
|
||||
for (int x = 0; x < bitmap->width(); ++x)
|
||||
bitmap->set_pixel(x, y, colors[(x * bitmap->width() + y) % number_of_colors]);
|
||||
|
||||
TRY_OR_FAIL((test_roundtrip<Gfx::WebPWriter, Gfx::WebPImageDecoderPlugin>(bitmap)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(test_webp_icc)
|
||||
{
|
||||
auto sRGB_icc_profile = MUST(Gfx::ICC::sRGB());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue