From 1881a8df4b7f34265a3d0674aec0608b39be530e Mon Sep 17 00:00:00 2001 From: Psychpsyo Date: Wed, 4 Dec 2024 19:08:56 +0100 Subject: [PATCH] LibGfx: Set png interlace handling on interlaced images --- Libraries/LibGfx/ImageFormats/PNGLoader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Libraries/LibGfx/ImageFormats/PNGLoader.cpp b/Libraries/LibGfx/ImageFormats/PNGLoader.cpp index 600debb1574..c1901bab459 100644 --- a/Libraries/LibGfx/ImageFormats/PNGLoader.cpp +++ b/Libraries/LibGfx/ImageFormats/PNGLoader.cpp @@ -115,7 +115,8 @@ ErrorOr PNGImageDecoderPlugin::initialize() u32 height = 0; int bit_depth = 0; int color_type = 0; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); + int interlace_type = 0; + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, nullptr, nullptr); m_context->size = { static_cast(width), static_cast(height) }; if (color_type == PNG_COLOR_TYPE_PALETTE) @@ -133,6 +134,9 @@ ErrorOr PNGImageDecoderPlugin::initialize() if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb(png_ptr); + if (interlace_type != PNG_INTERLACE_NONE) + png_set_interlace_handling(png_ptr); + png_set_filler(png_ptr, 0xFF, PNG_FILLER_AFTER); png_set_bgr(png_ptr);