mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00:00
LibGfx/GIF: Decode the header in create()
Again, header includes the logical screen descriptor here. This is done as a part of #19893.
This commit is contained in:
parent
294217586b
commit
500097de82
1 changed files with 3 additions and 14 deletions
|
@ -417,8 +417,6 @@ static ErrorOr<void> load_header_and_logical_screen(GIFLoadingContext& context)
|
|||
|
||||
static ErrorOr<void> load_gif_frame_descriptors(GIFLoadingContext& context)
|
||||
{
|
||||
TRY(load_header_and_logical_screen(context));
|
||||
|
||||
NonnullOwnPtr<GIFImageDescriptor> current_image = make<GIFImageDescriptor>();
|
||||
for (;;) {
|
||||
u8 sentinel = TRY(context.stream.read_value<u8>());
|
||||
|
@ -543,17 +541,6 @@ GIFImageDecoderPlugin::~GIFImageDecoderPlugin() = default;
|
|||
|
||||
IntSize GIFImageDecoderPlugin::size()
|
||||
{
|
||||
if (m_context->error_state == GIFLoadingContext::ErrorState::FailedToLoadFrameDescriptors) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (m_context->state < GIFLoadingContext::State::FrameDescriptorsLoaded) {
|
||||
if (load_gif_frame_descriptors(*m_context).is_error()) {
|
||||
m_context->error_state = GIFLoadingContext::ErrorState::FailedToLoadFrameDescriptors;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return { m_context->logical_screen.width, m_context->logical_screen.height };
|
||||
}
|
||||
|
||||
|
@ -566,7 +553,9 @@ bool GIFImageDecoderPlugin::sniff(ReadonlyBytes data)
|
|||
ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> GIFImageDecoderPlugin::create(ReadonlyBytes data)
|
||||
{
|
||||
FixedMemoryStream stream { data };
|
||||
return adopt_nonnull_own_or_enomem(new (nothrow) GIFImageDecoderPlugin(move(stream)));
|
||||
auto plugin = TRY(adopt_nonnull_own_or_enomem(new (nothrow) GIFImageDecoderPlugin(move(stream))));
|
||||
TRY(load_header_and_logical_screen(*plugin->m_context));
|
||||
return plugin;
|
||||
}
|
||||
|
||||
bool GIFImageDecoderPlugin::is_animated()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue