diff options
author | Peter Nelson <peter@peterdn.com> | 2020-04-25 13:51:00 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-25 16:49:09 +0200 |
commit | 2cd9716b3896062b226875257197f2bf96984351 (patch) | |
tree | 3bd190af582af8d587de3dd528c063e887f857e4 /Libraries/LibGfx/ImageDecoder.h | |
parent | df0d6e241ce0ef68723d03e69e7b69a009e102bd (diff) | |
download | serenity-2cd9716b3896062b226875257197f2bf96984351.zip |
LibGfx: Add a sniff method to ImageDecoder and implement for GIF and PNG
The sniff method is intended to be used for content sniffing. It should be a
cheap test to rapidly rule out whether a candidate image can be successfully
decoded. For the GIF and PNG implementations it simply attempts to decode the
image header, returning true if successful and false if not.
Diffstat (limited to 'Libraries/LibGfx/ImageDecoder.h')
-rw-r--r-- | Libraries/LibGfx/ImageDecoder.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Libraries/LibGfx/ImageDecoder.h b/Libraries/LibGfx/ImageDecoder.h index 6feb4e693b..f300cb4871 100644 --- a/Libraries/LibGfx/ImageDecoder.h +++ b/Libraries/LibGfx/ImageDecoder.h @@ -45,6 +45,8 @@ public: virtual void set_volatile() = 0; [[nodiscard]] virtual bool set_nonvolatile() = 0; + virtual bool sniff() = 0; + protected: ImageDecoderPlugin() {} }; @@ -60,6 +62,7 @@ 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(); }; private: ImageDecoder(const u8*, size_t); |