diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-05-16 18:02:54 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-05-16 18:04:09 +0300 |
commit | b8c30fb80a24ba87a7443364a1737ae636fbf6bf (patch) | |
tree | 4afff2fdc304d66cab9dffacca1f35f673fc42a3 /source/blender/blenkernel | |
parent | c729ddd7414ad0b25b9e4651e12ec4e4e4043775 (diff) |
Fix image saving incorrectly overrding non-color data color space
In such cases we should not automatically change the color space.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/image_save.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc index 46407f622ba..0230cf89d06 100644 --- a/source/blender/blenkernel/intern/image_save.cc +++ b/source/blender/blenkernel/intern/image_save.cc @@ -102,6 +102,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts, if (ibuf) { Scene *scene = opts->scene; 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 */ @@ -119,6 +120,9 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts, opts->im_format.imtype = R_IMF_IMTYPE_PNG; opts->im_format.compress = ibuf->foptions.quality; opts->im_format.planes = ibuf->planes; + if (!IMB_colormanagement_space_name_is_data(ima_colorspace)) { + ima_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE); + } } else { BKE_image_format_from_imbuf(&opts->im_format, ibuf); @@ -134,8 +138,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts, /* Default to saving in the same colorspace as the image setting. */ if (!opts->save_as_render) { - BKE_color_managed_colorspace_settings_copy(&opts->im_format.linear_colorspace_settings, - &ima->colorspace_settings); + STRNCPY(opts->im_format.linear_colorspace_settings.name, ima_colorspace); } opts->im_format.color_management = R_IMF_COLOR_MANAGEMENT_FOLLOW_SCENE; @@ -219,7 +222,9 @@ void BKE_image_save_options_update(ImageSaveOptions *opts, Image *image) BKE_color_managed_colorspace_settings_copy(&opts->im_format.linear_colorspace_settings, &image->colorspace_settings); } - else if (opts->im_format.imtype != opts->prev_imtype) { + else if (opts->im_format.imtype != opts->prev_imtype && + !IMB_colormanagement_space_name_is_data( + opts->im_format.linear_colorspace_settings.name)) { const bool linear_float_output = BKE_imtype_requires_linear_float(opts->im_format.imtype); /* TODO: detect if the colorspace is linear, not just equal to scene linear. */ |