From cf69763b54fde0dde6f2206c13d00b02669d6ba0 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Fri, 15 Jul 2022 18:37:27 +0200 Subject: [PATCH] LibGfx: Compress PNGs with a better compression level While for a general purpose encoder a good balance between compression speed and size by default is important, in case of PNG it don't matter that much, as it was said in #14594. Also note that it's not the best we can have. We use zlib's compression level, which has a range of 0-4, while our deflate implementation ranges from 0 to 5. --- Userland/Libraries/LibGfx/PNGWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/PNGWriter.cpp b/Userland/Libraries/LibGfx/PNGWriter.cpp index 26662774bf..7087091b3d 100644 --- a/Userland/Libraries/LibGfx/PNGWriter.cpp +++ b/Userland/Libraries/LibGfx/PNGWriter.cpp @@ -250,7 +250,7 @@ void PNGWriter::add_IDAT_chunk(Gfx::Bitmap const& bitmap) uncompressed_block_data.append(best_filter.buffer); } - auto maybe_zlib_buffer = Compress::ZlibCompressor::compress_all(uncompressed_block_data); + auto maybe_zlib_buffer = Compress::ZlibCompressor::compress_all(uncompressed_block_data, Compress::ZlibCompressionLevel::Best); if (!maybe_zlib_buffer.has_value()) { // FIXME: Handle errors. VERIFY_NOT_REACHED();