[Bf-blender-cvs] [b0c4133] master: Followup for fix T37718: image was not saving with proper settings second time

Sergey Sharybin noreply at git.blender.org
Thu Dec 19 12:21:13 CET 2013


Commit: b0c4133c67ce5fca7c3aa5abbd5a745c3d812525
Author: Sergey Sharybin
Date:   Thu Dec 19 17:17:40 2013 +0600
http://developer.blender.org/rBb0c4133c67ce5fca7c3aa5abbd5a745c3d812525

Followup for fix T37718: image was not saving with proper settings second time

This was actually a regression after color management re-implementation, need
to copy settings from saved image buffer to an original one since they might
be modified during save.

Also noticed image format planes detection didn't work properly from an image
buffer. Made it so save operator works fine now, but also marked a TODO in
BKE_imbuf_to_image_format() which needs to be investigated further.

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

M	source/blender/blenkernel/intern/image.c
M	source/blender/editors/space_image/image_ops.c

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

diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 74e32d9..3d59b71 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1497,6 +1497,12 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i
 	}
 
 	/* planes */
+	/* TODO(sergey): Channels doesn't correspond actual planes used for image buffer
+	 *               For example byte buffer will have 4 channels but it might easily
+	 *               be BW or RGB image.
+	 *
+	 *               Need to use im_format->planes = imbuf->planes instead?
+	 */
 	switch (imbuf->channels) {
 		case 0:
 		case 4: im_format->planes = R_IMF_PLANES_RGBA;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index a2f49af..7120a69 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1233,8 +1233,6 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
 		Image *ima = sima->image;
 		short is_depth_set = FALSE;
 
-		simopts->im_format.planes = ibuf->planes;
-
 		if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) {
 			/* imtype */
 			simopts->im_format = scene->r.im_format;
@@ -1250,6 +1248,9 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
 			}
 			simopts->im_format.quality = ibuf->ftype & 0xff;
 		}
+
+		simopts->im_format.planes = ibuf->planes;
+
 		//simopts->subimtype = scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */
 
 		BLI_strncpy(simopts->filepath, ibuf->name, sizeof(simopts->filepath));
@@ -1430,8 +1431,16 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
 
 		WM_cursor_wait(0);
 
-		if (colormanaged_ibuf != ibuf)
+		if (colormanaged_ibuf != ibuf) {
+			/* This guys might be modified by image buffer write functions,
+			 * need to copy them back from color managed image buffer to an
+			 * original one, so file type of image is being properly updated.
+			 */
+			ibuf->ftype = colormanaged_ibuf->ftype;
+			ibuf->planes = colormanaged_ibuf->planes;
+
 			IMB_freeImBuf(colormanaged_ibuf);
+		}
 	}
 
 	ED_space_image_release_buffer(sima, ibuf, lock);




More information about the Bf-blender-cvs mailing list