mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 11:28:11 +00:00
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.
This commit is contained in:
parent
df0d6e241c
commit
2cd9716b38
5 changed files with 16 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue