diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-07-03 19:23:55 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-07-03 19:30:58 +0300 |
commit | e42609db49b5ececb989167f5e1c14e5cff4ce4d (patch) | |
tree | 46bf626f315878d860422f4ba2d14fe9f101b78a /source/blender/imbuf | |
parent | 97b431e42dd2a87eed08423afc42a0ceb7448bff (diff) |
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.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/intern/png.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 1b6b413838d..b0e4af29ae6 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: |