From fc1ae52994016fc4d43053caa412212726f7e223 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 30 May 2022 14:23:45 +0200 Subject: 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. --- source/blender/blenkernel/BKE_image_save.h | 3 ++- source/blender/blenkernel/intern/image_save.cc | 9 +++++---- source/blender/editors/space_image/image_ops.c | 6 +++--- source/blender/makesrna/intern/rna_image_api.c | 5 ++--- 4 files changed, 12 insertions(+), 11 deletions(-) (limited to 'source') 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, -- cgit v1.2.3