From a690e68b1cdfbeffd7ee2e4500ccd81ae773dd2e Mon Sep 17 00:00:00 2001 From: Joseph Davies Date: Tue, 12 Nov 2024 02:28:16 -0800 Subject: [PATCH] Support Greyscale PNGs created by Pngcrush. Pngcrush optimizer will sometimes create greyscale images for the cursor resources. These are not loaded correctly without being explicitly converted. --- Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp b/Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp index bc53256ce8..4741e25365 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp @@ -133,12 +133,13 @@ plMipmap* plPNG::IRead(hsStream* inStream) channels = 3; break; case PNG_COLOR_TYPE_GRAY: - - if (bitdepth < 8) { + if (bitdepth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); - } - bitdepth = 8; + [[fallthrough]]; + case PNG_COLOR_TYPE_GRAY_ALPHA: + png_set_gray_to_rgb(png_ptr); + channels = 3; break; }