[Bf-blender-cvs] [fc1ae529940] master: Fix T98444: Image.save_render not using scene output file type

Brecht Van Lommel noreply at git.blender.org
Mon May 30 16:26:24 CEST 2022


Commit: fc1ae52994016fc4d43053caa412212726f7e223
Author: Brecht Van Lommel
Date:   Mon May 30 14:23:45 2022 +0200
Branches: master
https://developer.blender.org/rBfc1ae52994016fc4d43053caa412212726f7e223

Fix T98444: Image.save_render not using scene output file type

Also simplify logic because (source == IMA_SRC_VIEWER) and
ELEM(type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) are the same
thing.

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

M	source/blender/blenkernel/BKE_image_save.h
M	source/blender/blenkernel/intern/image_save.cc
M	source/blender/editors/space_image/image_ops.c
M	source/blender/makesrna/intern/rna_image_api.c

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

diff --git a/source/blender/blenkernel/BKE_image_save.h b/source/blender/blenkernel/BKE_image_save.h
index b5db15bb174..673a7dffb82 100644
--- a/source/blender/blenkernel/BKE_image_save.h
+++ b/source/blender/blenkernel/BKE_image_save.h
@@ -46,7 +46,8 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
                                  struct Scene *scene,
                                  struct Image *ima,
                                  struct ImageUser *iuser,
-                                 const bool guess_path);
+                                 const bool guess_path,
+                                 const bool save_as_render);
 void BKE_image_save_options_update(struct ImageSaveOptions *opts, struct Image *ima);
 void BKE_image_save_options_free(struct ImageSaveOptions *opts);
 
diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc
index b67d3490e03..910ac15d1c5 100644
--- a/source/blender/blenkernel/intern/image_save.cc
+++ b/source/blender/blenkernel/intern/image_save.cc
@@ -78,7 +78,8 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
                                  Scene *scene,
                                  Image *ima,
                                  ImageUser *iuser,
-                                 const bool guess_path)
+                                 const bool guess_path,
+                                 const bool save_as_render)
 {
   /* For saving a tiled image we need an iuser, so use a local one if there isn't already one. */
   ImageUser save_iuser;
@@ -92,7 +93,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
 
   opts->bmain = bmain;
   opts->scene = scene;
-  opts->save_as_render = ima->source == IMA_SRC_VIEWER;
+  opts->save_as_render = ima->source == IMA_SRC_VIEWER || save_as_render;
 
   BKE_image_format_init(&opts->im_format, false);
 
@@ -104,8 +105,8 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
     bool is_depth_set = false;
     const char *ima_colorspace = ima->colorspace_settings.name;
 
-    if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) {
-      /* imtype */
+    if (opts->save_as_render) {
+      /* Render/compositor output or user chose to save with render settings. */
       BKE_image_format_init_for_write(&opts->im_format, scene, NULL);
       is_depth_set = true;
       if (!BKE_image_is_multiview(ima)) {
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 69efd5eaabf..bd1cb3a345e 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1727,7 +1727,7 @@ static ImageSaveData *image_save_as_init(bContext *C, wmOperator *op)
   isd->image = image;
   isd->iuser = iuser;
 
-  if (!BKE_image_save_options_init(&isd->opts, bmain, scene, image, iuser, true)) {
+  if (!BKE_image_save_options_init(&isd->opts, bmain, scene, image, iuser, true, false)) {
     BKE_image_save_options_free(&isd->opts);
     MEM_freeN(isd);
     return NULL;
@@ -1994,7 +1994,7 @@ static int image_save_exec(bContext *C, wmOperator *op)
     return OPERATOR_FINISHED;
   }
 
-  if (!BKE_image_save_options_init(&opts, bmain, scene, image, iuser, false)) {
+  if (!BKE_image_save_options_init(&opts, bmain, scene, image, iuser, false, false)) {
     BKE_image_save_options_free(&opts);
     return OPERATOR_CANCELLED;
   }
@@ -2266,7 +2266,7 @@ bool ED_image_save_all_modified(const bContext *C, ReportList *reports)
         if (image_has_valid_path(ima)) {
           ImageSaveOptions opts;
           Scene *scene = CTX_data_scene(C);
-          if (!BKE_image_save_options_init(&opts, bmain, scene, ima, NULL, false)) {
+          if (!BKE_image_save_options_init(&opts, bmain, scene, ima, NULL, false, false)) {
             bool saved_successfully = BKE_image_save(reports, bmain, ima, NULL, &opts);
             ok = ok && saved_successfully;
           }
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index bac8f214441..46bb0df5c11 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -59,9 +59,8 @@ static void rna_Image_save_render(
 
   ImageSaveOptions opts;
 
-  if (BKE_image_save_options_init(&opts, bmain, scene, image, NULL, false)) {
+  if (BKE_image_save_options_init(&opts, bmain, scene, image, NULL, false, true)) {
     opts.save_copy = true;
-    opts.save_as_render = true;
     STRNCPY(opts.filepath, path);
 
     if (!BKE_image_save(reports, bmain, image, NULL, &opts)) {
@@ -83,7 +82,7 @@ static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *r
   Scene *scene = CTX_data_scene(C);
   ImageSaveOptions opts;
 
-  if (BKE_image_save_options_init(&opts, bmain, scene, image, NULL, false)) {
+  if (BKE_image_save_options_init(&opts, bmain, scene, image, NULL, false, false)) {
     if (!BKE_image_save(reports, bmain, image, NULL, &opts)) {
       BKE_reportf(reports,
                   RPT_ERROR,



More information about the Bf-blender-cvs mailing list