mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
LibGfx: Use content sniffing to choose which ImageDecoder plugin to use
This commit is contained in:
parent
2cd9716b38
commit
9a2c8102cd
Notes:
sideshowbarker
2024-07-19 07:18:36 +09:00
Author: https://github.com/peterdn Commit: https://github.com/SerenityOS/serenity/commit/9a2c8102cd8 Pull-request: https://github.com/SerenityOS/serenity/pull/1950
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
Reference in a new issue