mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
LibGfx: Add support for animated images to ImageDecoder{Plugin}
Adds methods to determine whether an image is animated, how many times the animation loops, the number of frames, and to get individual frames. Implements stubs of these methods for PNGImageDecoderPlugin and GIFImageDecoderPlugin.
This commit is contained in:
parent
eec99b23a0
commit
d22bb92764
5 changed files with 71 additions and 2 deletions
|
@ -26,15 +26,20 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <LibGfx/Size.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
class Bitmap;
|
||||
|
||||
struct ImageFrameDescriptor {
|
||||
RefPtr<Bitmap> image;
|
||||
int duration { 0 };
|
||||
};
|
||||
|
||||
class ImageDecoderPlugin {
|
||||
public:
|
||||
virtual ~ImageDecoderPlugin() {}
|
||||
|
@ -47,6 +52,11 @@ public:
|
|||
|
||||
virtual bool sniff() = 0;
|
||||
|
||||
virtual bool is_animated() = 0;
|
||||
virtual size_t loop_count() = 0;
|
||||
virtual size_t frame_count() = 0;
|
||||
virtual ImageFrameDescriptor frame(size_t i) = 0;
|
||||
|
||||
protected:
|
||||
ImageDecoderPlugin() {}
|
||||
};
|
||||
|
@ -62,7 +72,11 @@ public:
|
|||
RefPtr<Gfx::Bitmap> bitmap() const;
|
||||
void set_volatile() { m_plugin->set_volatile(); }
|
||||
[[nodiscard]] bool set_nonvolatile() { return m_plugin->set_nonvolatile(); }
|
||||
bool sniff() { return m_plugin->sniff(); };
|
||||
bool sniff() const { return m_plugin->sniff(); }
|
||||
bool is_animated() const { return m_plugin->is_animated(); }
|
||||
size_t loop_count() const { return m_plugin->loop_count(); }
|
||||
size_t frame_count() const { return m_plugin->frame_count(); }
|
||||
ImageFrameDescriptor frame(size_t i) const { return m_plugin->frame(i); }
|
||||
|
||||
private:
|
||||
ImageDecoder(const u8*, size_t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue