summaryrefslogtreecommitdiff
path: root/src/spriteloader
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-06-14 14:11:08 +0000
committertruelight <truelight@openttd.org>2007-06-14 14:11:08 +0000
commita61f0d90494b39249135314cc81d74776b38a3e6 (patch)
tree800322d3ed99ab7e6ccbae65f2060e382c1827b4 /src/spriteloader
parent0e5a6661f7054c554d006f78c50123c8887b6f85 (diff)
downloadopenttd-a61f0d90494b39249135314cc81d74776b38a3e6.tar.xz
(svn r10156) -Fix: PNG loader can now load 8bpp palette images and greyscale images
Diffstat (limited to 'src/spriteloader')
-rw-r--r--src/spriteloader/png.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/spriteloader/png.cpp b/src/spriteloader/png.cpp
index bd735ce43..71f64a2bf 100644
--- a/src/spriteloader/png.cpp
+++ b/src/spriteloader/png.cpp
@@ -114,8 +114,14 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i
if (!mask) {
if (bit_depth == 16) png_set_strip_16(png_ptr);
- if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png_ptr);
- /* TODO 32bpp: Convert grayscale to rgb */
+ if (color_type == PNG_COLOR_TYPE_PALETTE) {
+ png_set_palette_to_rgb(png_ptr);
+ color_type = PNG_COLOR_TYPE_RGB;
+ }
+ if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
+ png_set_gray_to_rgb(png_ptr);
+ color_type = PNG_COLOR_TYPE_RGB;
+ }
#ifdef TTD_LITTLE_ENDIAN
png_set_bgr(png_ptr);