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:
Peter Nelson 2020-04-25 13:51:00 +01:00 committed by Andreas Kling
commit 2cd9716b38
Notes: sideshowbarker 2024-07-19 07:18:40 +09:00
5 changed files with 16 additions and 0 deletions

View file

@ -725,4 +725,9 @@ bool PNGImageDecoderPlugin::set_nonvolatile()
return m_context->bitmap->set_nonvolatile();
}
bool PNGImageDecoderPlugin::sniff()
{
return decode_png_header(*m_context);
}
}