mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
LibGfx: Implement is_animated() and frame_count() for webp plugin
This commit is contained in:
parent
0393a37843
commit
3c5450b8be
2 changed files with 22 additions and 7 deletions
|
@ -519,8 +519,15 @@ ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> WebPImageDecoderPlugin::create(Readon
|
|||
|
||||
bool WebPImageDecoderPlugin::is_animated()
|
||||
{
|
||||
// FIXME
|
||||
return false;
|
||||
if (m_context->state == WebPLoadingContext::State::Error)
|
||||
return false;
|
||||
|
||||
if (m_context->state < WebPLoadingContext::State::FirstChunkDecoded) {
|
||||
if (decode_webp_first_chunk(*m_context).is_error())
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_context->first_chunk->type == FourCC("VP8X") && m_context->vp8x_header.has_animation;
|
||||
}
|
||||
|
||||
size_t WebPImageDecoderPlugin::loop_count()
|
||||
|
@ -531,8 +538,15 @@ size_t WebPImageDecoderPlugin::loop_count()
|
|||
|
||||
size_t WebPImageDecoderPlugin::frame_count()
|
||||
{
|
||||
// FIXME
|
||||
return 1;
|
||||
if (!is_animated())
|
||||
return 1;
|
||||
|
||||
if (m_context->state < WebPLoadingContext::State::ChunksDecoded) {
|
||||
if (decode_webp_chunks(*m_context).is_error())
|
||||
return 1;
|
||||
}
|
||||
|
||||
return m_context->animation_frame_chunks.size();
|
||||
}
|
||||
|
||||
ErrorOr<ImageFrameDescriptor> WebPImageDecoderPlugin::frame(size_t index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue