aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAndrius <andrius@ambernet.lt>2015-01-30 15:38:44 +0200
committerAndrius <andrius@ambernet.lt>2015-01-30 15:38:44 +0200
commitb3e4afd56c9d57544498259f1b0b4505991197a0 (patch)
treee5e94cea8897c16cd0efefefb5a660a802323c93 /tools
parent06bac9f4321f91b519204f785be8bb44c208cfe2 (diff)
Fix TexturePacker segfault with grayscale PNGs.
see http://forum.kodi.tv/showthread.php?tid=216503
Diffstat (limited to 'tools')
-rw-r--r--tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp9
1 files changed, 8 insertions, 1 deletions
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);