From b3e4afd56c9d57544498259f1b0b4505991197a0 Mon Sep 17 00:00:00 2001 From: Andrius Date: Fri, 30 Jan 2015 15:38:44 +0200 Subject: Fix TexturePacker segfault with grayscale PNGs. see http://forum.kodi.tv/showthread.php?tid=216503 --- tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp b/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp index 38b8afa738..f57dc83b83 100644 --- a/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp +++ b/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp @@ -165,7 +165,14 @@ bool PNGDecoder::LoadFile(const std::string &filename, DecodedFrames &frames) /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ //png_set_swap_alpha(png_ptr); - + //libsquish only eats 32bit RGBA, must convert grayscale into this format + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + png_set_expand_gray_1_2_4_to_8(png_ptr); + png_set_gray_to_rgb(png_ptr); + } + // Update the png info struct. png_read_update_info(png_ptr, info_ptr); -- cgit v1.2.3