diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-01 21:32:54 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-01 21:32:54 +0200 |
commit | 7be9cf8d36c42a8ef9e96f0750554e8aa811d9c0 (patch) | |
tree | 25a07bd62df1c6333c2d0049a96c6e19ece9beb0 /Libraries/LibGfx | |
parent | 6ed11f1d1c268dec07c5bc595b4493a7f8efa6f1 (diff) | |
download | serenity-7be9cf8d36c42a8ef9e96f0750554e8aa811d9c0.zip |
LibGfx: Add ImageDecoder factory overload for ByteBuffers
Diffstat (limited to 'Libraries/LibGfx')
-rw-r--r-- | Libraries/LibGfx/ImageDecoder.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Libraries/LibGfx/ImageDecoder.h b/Libraries/LibGfx/ImageDecoder.h index bcc08c675c..7b8b5edf9d 100644 --- a/Libraries/LibGfx/ImageDecoder.h +++ b/Libraries/LibGfx/ImageDecoder.h @@ -26,6 +26,7 @@ #pragma once +#include <AK/ByteBuffer.h> #include <AK/OwnPtr.h> #include <AK/RefCounted.h> #include <AK/RefPtr.h> @@ -42,7 +43,7 @@ struct ImageFrameDescriptor { class ImageDecoderPlugin { public: - virtual ~ImageDecoderPlugin() {} + virtual ~ImageDecoderPlugin() { } virtual Size size() = 0; virtual RefPtr<Gfx::Bitmap> bitmap() = 0; @@ -58,12 +59,13 @@ public: virtual ImageFrameDescriptor frame(size_t i) = 0; protected: - ImageDecoderPlugin() {} + ImageDecoderPlugin() { } }; class ImageDecoder : public RefCounted<ImageDecoder> { public: static NonnullRefPtr<ImageDecoder> create(const u8* data, size_t size) { return adopt(*new ImageDecoder(data, size)); } + static NonnullRefPtr<ImageDecoder> create(const ByteBuffer& data) { return adopt(*new ImageDecoder(data.data(), data.size())); } ~ImageDecoder(); Size size() const { return m_plugin->size(); } |