浏览代码

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.
Luke 4 年之前
父节点
当前提交
c3d4fbb2a5
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      Userland/Libraries/LibGfx/PNGLoader.cpp

+ 2 - 2
Userland/Libraries/LibGfx/PNGLoader.cpp

@@ -28,7 +28,7 @@
 #include <AK/Endian.h>
 #include <AK/LexicalPath.h>
 #include <AK/MappedFile.h>
-#include <LibCompress/Gzip.h>
+#include <LibCompress/Zlib.h>
 #include <LibGfx/PNGLoader.h>
 #include <fcntl.h>
 #include <math.h>
@@ -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;