From 090c950c74ce7bd11c30c38697f3aa711ed3f564 Mon Sep 17 00:00:00 2001 From: Joseph Davies Date: Sat, 25 Jun 2011 20:22:53 -0700 Subject: [PATCH] Fix for plPNG::IRead improperly handling 24-bit RGB and non-transparent paletted images. --- Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp b/Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp index ff7e9026..768a7ef7 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plPNG.cpp @@ -127,6 +127,10 @@ plMipmap* plPNG::IRead(hsStream* inStream) if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { png_set_tRNS_to_alpha(png_ptr); channels += 1; + } else if (channels == 3) { + // Add an opaque alpha channel if still none exists + png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); + channels = 4; } // Invert color byte-order as used by plMipmap for DirectX