[Bf-blender-cvs] [e42609d] master: Fix T45283: Blender crashes on some grayscale PNGs with alpha.

Bastien Montagne noreply at git.blender.org
Fri Jul 3 18:33:00 CEST 2015


Commit: e42609db49b5ececb989167f5e1c14e5cff4ce4d
Author: Bastien Montagne
Date:   Fri Jul 3 18:23:55 2015 +0200
Branches: master
https://developer.blender.org/rBe42609db49b5ececb989167f5e1c14e5cff4ce4d

Fix T45283: Blender crashes on some grayscale PNGs with alpha.

PNG_COLOR_TYPE_GRAY colortype can have some values for alpha, in the same way as
PNG_COLOR_TYPE_PALETTE colortype.

In this case, we need two channels (grayscale and alpha), not one.

===================================================================

M	source/blender/imbuf/intern/png.c

===================================================================

diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 1b6b413..b0e4af2 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -584,6 +584,10 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[I
 			if (bit_depth < 8) {
 				png_set_expand(png_ptr);
 				bit_depth = 8;
+				if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
+					/* PNG_COLOR_TYPE_GRAY may also have alpha 'values', like with palette. */
+					bytesperpixel = 2;
+				}
 			}
 			break;
 		default:




More information about the Bf-blender-cvs mailing list