2019-10-15 21:48:08 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/NonnullRefPtr.h>
|
|
|
|
#include <AK/OwnPtr.h>
|
|
|
|
#include <AK/RefCounted.h>
|
|
|
|
#include <LibDraw/Size.h>
|
|
|
|
|
|
|
|
class GraphicsBitmap;
|
|
|
|
|
2019-10-19 19:56:49 +02:00
|
|
|
class ImageDecoderPlugin {
|
2019-10-15 21:48:08 +02:00
|
|
|
public:
|
2019-10-19 19:56:49 +02:00
|
|
|
virtual ~ImageDecoderPlugin() {}
|
2019-10-15 21:48:08 +02:00
|
|
|
|
|
|
|
virtual Size size() = 0;
|
|
|
|
virtual RefPtr<GraphicsBitmap> bitmap() = 0;
|
|
|
|
|
2019-12-18 20:50:58 +01:00
|
|
|
virtual void set_volatile() = 0;
|
|
|
|
[[nodiscard]] virtual bool set_nonvolatile() = 0;
|
|
|
|
|
2019-10-15 21:48:08 +02:00
|
|
|
protected:
|
2019-10-19 19:56:49 +02:00
|
|
|
ImageDecoderPlugin() {}
|
2019-10-15 21:48:08 +02:00
|
|
|
};
|
|
|
|
|
2019-10-19 19:56:49 +02:00
|
|
|
class ImageDecoder : public RefCounted<ImageDecoder> {
|
2019-10-15 21:48:08 +02:00
|
|
|
public:
|
2019-10-19 19:56:49 +02:00
|
|
|
static NonnullRefPtr<ImageDecoder> create(const u8* data, size_t size) { return adopt(*new ImageDecoder(data, size)); }
|
|
|
|
~ImageDecoder();
|
2019-10-15 21:48:08 +02:00
|
|
|
|
|
|
|
Size size() const { return m_plugin->size(); }
|
|
|
|
int width() const { return size().width(); }
|
|
|
|
int height() const { return size().height(); }
|
|
|
|
RefPtr<GraphicsBitmap> bitmap() const { return m_plugin->bitmap(); }
|
2019-12-18 20:50:58 +01:00
|
|
|
void set_volatile() { m_plugin->set_volatile(); }
|
|
|
|
[[nodiscard]] bool set_nonvolatile() { return m_plugin->set_nonvolatile(); }
|
2019-10-15 21:48:08 +02:00
|
|
|
|
|
|
|
private:
|
2019-10-19 19:56:49 +02:00
|
|
|
ImageDecoder(const u8*, size_t);
|
2019-10-15 21:48:08 +02:00
|
|
|
|
2019-10-19 19:56:49 +02:00
|
|
|
mutable OwnPtr<ImageDecoderPlugin> m_plugin;
|
2019-10-15 21:48:08 +02:00
|
|
|
};
|