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.
This commit is contained in:
Brecht Van Lommel 2022-05-30 14:23:45 +02:00
parent 65bd9974d1
commit fc1ae52994
Notes: blender-bot 2023-02-14 02:22:13 +01:00
Referenced by issue #98444, Regression: image.save_render() command changes color profile and file type when saving.
4 changed files with 12 additions and 11 deletions

View File

@ -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);

View File

@ -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)) {

View File

@ -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;
}

View File

@ -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,