mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
LibGfx: Add ImageDecoder factory overload for ByteBuffers
This commit is contained in:
parent
6ed11f1d1c
commit
7be9cf8d36
1 changed files with 4 additions and 2 deletions
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/ByteBuffer.h>
|
||||||
#include <AK/OwnPtr.h>
|
#include <AK/OwnPtr.h>
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
|
@ -42,7 +43,7 @@ struct ImageFrameDescriptor {
|
||||||
|
|
||||||
class ImageDecoderPlugin {
|
class ImageDecoderPlugin {
|
||||||
public:
|
public:
|
||||||
virtual ~ImageDecoderPlugin() {}
|
virtual ~ImageDecoderPlugin() { }
|
||||||
|
|
||||||
virtual Size size() = 0;
|
virtual Size size() = 0;
|
||||||
virtual RefPtr<Gfx::Bitmap> bitmap() = 0;
|
virtual RefPtr<Gfx::Bitmap> bitmap() = 0;
|
||||||
|
@ -58,12 +59,13 @@ public:
|
||||||
virtual ImageFrameDescriptor frame(size_t i) = 0;
|
virtual ImageFrameDescriptor frame(size_t i) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ImageDecoderPlugin() {}
|
ImageDecoderPlugin() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImageDecoder : public RefCounted<ImageDecoder> {
|
class ImageDecoder : public RefCounted<ImageDecoder> {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<ImageDecoder> create(const u8* data, size_t size) { return adopt(*new ImageDecoder(data, size)); }
|
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();
|
~ImageDecoder();
|
||||||
|
|
||||||
Size size() const { return m_plugin->size(); }
|
Size size() const { return m_plugin->size(); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue