Browse Source

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 years ago
parent
commit
c3d4fbb2a5
1 changed files with 2 additions and 2 deletions
  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;