mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibGfx: Use content sniffing to choose which ImageDecoder plugin to use
This commit is contained in:
parent
2cd9716b38
commit
9a2c8102cd
1 changed files with 11 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue