From c3d4fbb2a58a5b46d3808e526cea78eb05e47893 Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 28 Mar 2021 15:33:37 +0100 Subject: [PATCH] LibGfx: Use zlib instead of just deflate when loading PNGs PNGs use deflate with zlib, however we were just skipping the zlib bytes and then piping it into deflate decompressor. Since we have a zlib decompressor, lets use that instead. This has the added benefit of extra error checking. --- Userland/Libraries/LibGfx/PNGLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp index 0699ebc9d2..ecc9c650be 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/PNGLoader.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -777,7 +777,7 @@ static bool decode_png_bitmap(PNGLoadingContext& context) if (context.color_type == 3 && context.palette_data.is_empty()) return false; // Didn't see a PLTE chunk for a palettized image, or it was empty. - auto result = Compress::DeflateDecompressor::decompress_all(context.compressed_data.span().slice(2)); + auto result = Compress::Zlib::decompress_all(context.compressed_data.span()); if (!result.has_value()) { context.state = PNGLoadingContext::State::Error; return false;