LibGfx: Use content sniffing to choose which ImageDecoder plugin to use

This commit is contained in:
Peter Nelson 2020-04-25 14:05:05 +01:00 committed by Andreas Kling
parent 2cd9716b38
commit 9a2c8102cd
Notes: sideshowbarker 2024-07-19 07:18:36 +09:00

View file

@ -25,6 +25,7 @@
*/
#include <LibGfx/ImageDecoder.h>
#include <LibGfx/GIFLoader.h>
#include <LibGfx/PNGLoader.h>
namespace Gfx {
@ -32,6 +33,16 @@ namespace Gfx {
ImageDecoder::ImageDecoder(const u8* data, size_t size)
{
m_plugin = make<PNGImageDecoderPlugin>(data, size);
if (m_plugin->sniff()) {
dbg() << "Decoding image as a PNG";
return;
}
m_plugin = make<GIFImageDecoderPlugin>(data, size);
if (m_plugin->sniff()) {
dbg() << "Decoding image as a GIF";
return;
}
}
ImageDecoder::~ImageDecoder()