summaryrefslogtreecommitdiff
path: root/src/spriteloader
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-04-14 16:07:17 +0000
committerrubidium <rubidium@openttd.org>2010-04-14 16:07:17 +0000
commit51ea33f92fa43b2061385463c1db32d9be7eaaf0 (patch)
treef864d188785022b56bb4f52d472ff3a73a9f3c35 /src/spriteloader
parentac6e8a211cf64000a1a5c1b4da93b983ed135698 (diff)
downloadopenttd-51ea33f92fa43b2061385463c1db32d9be7eaaf0.tar.xz
(svn r19628) -Change: support the tRNS chunk to read transparency information for RGB PNGs (Szvengar)
Diffstat (limited to 'src/spriteloader')
-rw-r--r--src/spriteloader/png.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/spriteloader/png.cpp b/src/spriteloader/png.cpp
index e72f44010..fa66ae3f1 100644
--- a/src/spriteloader/png.cpp
+++ b/src/spriteloader/png.cpp
@@ -132,7 +132,12 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i
}
if (colour_type == PNG_COLOR_TYPE_RGB) {
- png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
+ /* Create an alpha channel when there is a tRNS chunk */
+ png_set_tRNS_to_alpha(png_ptr);
+ } else {
+ png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
+ }
}
pixelsize = sizeof(uint32);