From 98e5e544b55d2d358fbf38df27e06a5dc3b36406 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 12 Aug 2013 07:47:44 +0000 Subject: [PATCH] Fix #36408: Setting `image.colorspace_settings.name` changes saved alpha Issue was caused by reload caused by input colorspace change. For generated images generated alpha flags weren't saved to DNA, which lead to fallback from 32 bit depth to 24 when doing any kind reload of generated image. The same alpha loss happens when you save .blend file with generated images. Now added generated depth to DNA, so reload image and .blend file wouldn't loss alpha. --- source/blender/blenkernel/intern/image.c | 4 +++- source/blender/makesdna/DNA_image_types.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 71289457ae9..86382c64ed3 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -723,6 +723,7 @@ Image *BKE_image_add_generated(Main *bmain, unsigned int width, unsigned int hei ima->gen_y = height; ima->gen_type = gen_type; ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0); + ima->gen_depth = depth; ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); @@ -2996,7 +2997,8 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) /* UV testgrid or black or solid etc */ if (ima->gen_x == 0) ima->gen_x = 1024; if (ima->gen_y == 0) ima->gen_y = 1024; - ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, + if (ima->gen_depth == 0) ima->gen_depth = 24; + ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, ima->gen_depth, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color, &ima->colorspace_settings); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ima->ok = IMA_OK_LOADED; diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index 456196771a6..dae520f458d 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -106,7 +106,7 @@ typedef struct Image { /* for generated images */ int gen_x, gen_y; char gen_type, gen_flag; - char gen_pad[2]; + short gen_depth; /* display aspect - for UV editing images resized for faster openGL display */ float aspx, aspy;