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.
This commit is contained in:
Bastien Montagne 2015-07-03 18:23:55 +02:00
parent 97b431e42d
commit e42609db49
Notes: blender-bot 2023-02-14 08:56:47 +01:00
Referenced by issue #45283, Blender crashes when trying to do anything with specific type of transparent image.
1 changed files with 4 additions and 0 deletions

View File

@ -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: