mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 16:16:43 +00:00
LibGfx/GIF: Correctly write frames with a non-null position
This commit is contained in:
parent
934516d75b
commit
fb79aa6159
Notes:
sideshowbarker
2024-07-17 07:14:09 +09:00
Author: https://github.com/LucasChollet
Commit: fb79aa6159
Pull-request: https://github.com/SerenityOS/serenity/pull/24416
Issue: https://github.com/SerenityOS/serenity/issues/24411
Reviewed-by: https://github.com/nico ✅
2 changed files with 13 additions and 8 deletions
|
@ -129,19 +129,23 @@ TEST_CASE(test_gif_animated)
|
|||
{
|
||||
auto bitmap_1 = TRY_OR_FAIL(TRY_OR_FAIL(create_test_rgb_bitmap())->cropped({ 0, 0, 16, 16 }));
|
||||
auto bitmap_2 = TRY_OR_FAIL(TRY_OR_FAIL(create_test_rgb_bitmap())->cropped({ 16, 16, 16, 16 }));
|
||||
auto bitmap_3 = TRY_OR_FAIL(bitmap_2->clone());
|
||||
|
||||
bitmap_3->scanline(3)[3] = Color(Color::NamedColor::Red).value();
|
||||
|
||||
auto stream_buffer = TRY_OR_FAIL(ByteBuffer::create_uninitialized(3072));
|
||||
FixedMemoryStream stream { Bytes { stream_buffer } };
|
||||
auto animation_writer = TRY_OR_FAIL(Gfx::GIFWriter::start_encoding_animation(stream, bitmap_1->size(), 0));
|
||||
TRY_OR_FAIL(animation_writer->add_frame(*bitmap_1, 100));
|
||||
TRY_OR_FAIL(animation_writer->add_frame(*bitmap_2, 200));
|
||||
TRY_OR_FAIL(animation_writer->add_frame_relative_to_last_frame(*bitmap_3, 200, *bitmap_2));
|
||||
|
||||
auto encoded_animation = ReadonlyBytes { stream_buffer.data(), stream.offset() };
|
||||
|
||||
auto decoder = TRY_OR_FAIL(Gfx::GIFImageDecoderPlugin::create(encoded_animation));
|
||||
|
||||
EXPECT_EQ(decoder->size(), bitmap_1->size());
|
||||
EXPECT_EQ(decoder->frame_count(), 2u);
|
||||
EXPECT_EQ(decoder->frame_count(), 3u);
|
||||
EXPECT_EQ(decoder->loop_count(), 0u);
|
||||
EXPECT(decoder->is_animated());
|
||||
|
||||
|
@ -152,6 +156,10 @@ TEST_CASE(test_gif_animated)
|
|||
auto const frame_2 = TRY_OR_FAIL(decoder->frame(1));
|
||||
EXPECT_EQ(frame_2.duration, 200);
|
||||
expect_bitmaps_equal(*frame_2.image, bitmap_2);
|
||||
|
||||
auto const frame_3 = TRY_OR_FAIL(decoder->frame(2));
|
||||
EXPECT_EQ(frame_3.duration, 200);
|
||||
expect_bitmaps_equal(*frame_3.image, bitmap_3);
|
||||
}
|
||||
|
||||
TEST_CASE(test_jpeg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue