diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-03-11 19:50:57 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-03-21 18:38:13 +0300 |
commit | 6e4d2fa9140864a13356b07ffca082817822987f (patch) | |
tree | cb8894c3b6898e82410f3edffe2fb9d85a3a2399 /source/blender/editors/space_image/image_ops.c | |
parent | 4abb8a14a2133f876c7718a8e09284baa62b1cf5 (diff) |
Cleanup: add image_format.cc for functions related to ImageFormatData
Also fixes missing code to read/write/free/copy color management settings
in various places. This can't be set through the UI currently, but still
should be handled consistently.
Diffstat (limited to 'source/blender/editors/space_image/image_ops.c')
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 3721ea81c04..35be7ffdb8b 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -38,6 +38,7 @@ #include "BKE_global.h" #include "BKE_icons.h" #include "BKE_image.h" +#include "BKE_image_format.h" #include "BKE_image_save.h" #include "BKE_layer.h" #include "BKE_lib_id.h" @@ -1736,7 +1737,7 @@ static int image_save_options_init(Main *bmain, if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { /* imtype */ - opts->im_format = scene->r.im_format; + BKE_image_format_copy(&opts->im_format, &scene->r.im_format); is_depth_set = true; if (!BKE_image_is_multiview(ima)) { /* In case multiview is disabled, @@ -1752,7 +1753,7 @@ static int image_save_options_init(Main *bmain, opts->im_format.planes = ibuf->planes; } else { - BKE_imbuf_to_image_format(&opts->im_format, ibuf); + BKE_image_format_from_imbuf(&opts->im_format, ibuf); } /* use the multiview image settings as the default */ @@ -1829,8 +1830,8 @@ static void image_save_options_from_op(Main *bmain, ImageFormatData *imf) { if (imf) { - BKE_color_managed_view_settings_free(&opts->im_format.view_settings); - opts->im_format = *imf; + BKE_image_format_free(&opts->im_format); + BKE_image_format_copy(&opts->im_format, imf); } if (RNA_struct_property_is_set(op->ptr, "filepath")) { @@ -1843,8 +1844,8 @@ static void image_save_options_to_op(ImageSaveOptions *opts, wmOperator *op) { if (op->customdata) { ImageSaveData *isd = op->customdata; - BKE_color_managed_view_settings_free(&isd->im_format.view_settings); - isd->im_format = opts->im_format; + BKE_image_format_free(&isd->im_format); + BKE_image_format_copy(&isd->im_format, &opts->im_format); } RNA_string_set(op->ptr, "filepath", opts->filepath); @@ -1878,7 +1879,7 @@ static void image_save_as_free(wmOperator *op) { if (op->customdata) { ImageSaveData *isd = op->customdata; - BKE_color_managed_view_settings_free(&isd->im_format.view_settings); + BKE_image_format_free(&isd->im_format); MEM_freeN(op->customdata); op->customdata = NULL; @@ -1920,6 +1921,8 @@ static int image_save_as_exec(bContext *C, wmOperator *op) BKE_image_free_packedfiles(image); } + BKE_image_save_options_free(&opts); + image_save_as_free(op); return OPERATOR_FINISHED; @@ -1948,6 +1951,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS BKE_image_save_options_init(&opts, bmain, scene); if (image_save_options_init(bmain, &opts, ima, iuser, true, save_as_render) == 0) { + BKE_image_save_options_free(&opts); return OPERATOR_CANCELLED; } image_save_options_to_op(&opts, op); @@ -1964,7 +1968,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS isd->image = ima; isd->iuser = iuser; - memcpy(&isd->im_format, &opts.im_format, sizeof(opts.im_format)); + BKE_image_format_copy(&isd->im_format, &opts.im_format); op->customdata = isd; /* show multiview save options only if image has multiviews */ @@ -1974,6 +1978,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS RNA_property_boolean_set(op->ptr, prop, BKE_image_is_multiview(ima)); image_filesel(C, op, opts.filepath); + BKE_image_save_options_free(&opts); return OPERATOR_RUNNING_MODAL; } @@ -2132,6 +2137,7 @@ static int image_save_exec(bContext *C, wmOperator *op) BKE_image_save_options_init(&opts, bmain, scene); if (image_save_options_init(bmain, &opts, image, iuser, false, false) == 0) { + BKE_image_save_options_free(&opts); return OPERATOR_CANCELLED; } image_save_options_from_op(bmain, &opts, op, NULL); @@ -2147,7 +2153,7 @@ static int image_save_exec(bContext *C, wmOperator *op) ok = true; } - BKE_color_managed_view_settings_free(&opts.im_format.view_settings); + BKE_image_save_options_free(&opts); if (ok) { return OPERATOR_FINISHED; @@ -2399,6 +2405,7 @@ bool ED_image_save_all_modified(const bContext *C, ReportList *reports) bool saved_successfully = BKE_image_save(reports, bmain, ima, NULL, &opts); ok = ok && saved_successfully; } + BKE_image_save_options_free(&opts); } } } |