summaryrefslogtreecommitdiff
path: root/Libraries/LibGfx/ImageDecoder.h
diff options
context:
space:
mode:
authorPeter Nelson <peter@peterdn.com>2020-05-03 17:12:54 +0100
committerAndreas Kling <kling@serenityos.org>2020-05-09 12:01:59 +0200
commitd22bb9276454937aa19a9bc867839e02434b0c30 (patch)
treefc46d763899d35cca18f66ed4b1d1f4d4500d7a4 /Libraries/LibGfx/ImageDecoder.h
parenteec99b23a0234d309ccecdb2baa6fff97526a6e9 (diff)
downloadserenity-d22bb9276454937aa19a9bc867839e02434b0c30.zip
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.
Diffstat (limited to 'Libraries/LibGfx/ImageDecoder.h')
-rw-r--r--Libraries/LibGfx/ImageDecoder.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/Libraries/LibGfx/ImageDecoder.h b/Libraries/LibGfx/ImageDecoder.h
index f300cb4871..bcc08c675c 100644
--- a/Libraries/LibGfx/ImageDecoder.h
+++ b/Libraries/LibGfx/ImageDecoder.h
@@ -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);