diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-03-11 20:21:05 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-03-22 16:15:20 +0300 |
commit | 3b5224b57c3cfc39a7998ecfc482e13bd6940e68 (patch) | |
tree | 1111ceb0a6501b7de81d4e0e59b6d424c9773665 /source/blender/blenkernel/intern/image_format.cc | |
parent | 2ebcb7fab3e237b7d00de3088c34780cd24f397b (diff) |
Cleanup: refactor passing of color management settings for image save
Make a copy of ImageFormatData that contains the effective color management
settings, and pass that along to the various functions. This will make it
possible to add more complex logic later.
For compositing nodes, passing along view and display settings through
many functions made it harder to add additional settings, so just get those
from the scene now.
Differential Revision: https://developer.blender.org/D14401
Diffstat (limited to 'source/blender/blenkernel/intern/image_format.cc')
-rw-r--r-- | source/blender/blenkernel/intern/image_format.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/image_format.cc b/source/blender/blenkernel/intern/image_format.cc index f0400417ffc..49f9ca6418f 100644 --- a/source/blender/blenkernel/intern/image_format.cc +++ b/source/blender/blenkernel/intern/image_format.cc @@ -14,6 +14,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -872,3 +873,39 @@ void BKE_image_format_from_imbuf(ImageFormatData *im_format, const ImBuf *imbuf) /* planes */ im_format->planes = imbuf->planes; } + +/* Color Management */ + +void BKE_image_format_color_management_copy(ImageFormatData *imf, const ImageFormatData *imf_src) +{ + BKE_color_managed_view_settings_free(&imf->view_settings); + + BKE_color_managed_display_settings_copy(&imf->display_settings, &imf_src->display_settings); + BKE_color_managed_view_settings_copy(&imf->view_settings, &imf_src->view_settings); + BKE_color_managed_colorspace_settings_copy(&imf->linear_colorspace_settings, + &imf_src->linear_colorspace_settings); +} + +void BKE_image_format_color_management_copy_from_scene(ImageFormatData *imf, const Scene *scene) +{ + BKE_color_managed_view_settings_free(&imf->view_settings); + + BKE_color_managed_display_settings_copy(&imf->display_settings, &scene->display_settings); + BKE_color_managed_view_settings_copy(&imf->view_settings, &scene->view_settings); + STRNCPY(imf->linear_colorspace_settings.name, + IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR)); +} + +/* Output */ + +void BKE_image_format_init_for_write(ImageFormatData *imf, + const Scene *scene_src, + const ImageFormatData *imf_src) +{ + *imf = (imf_src) ? *imf_src : scene_src->r.im_format; + + /* Use general scene settings also used for display. */ + BKE_color_managed_display_settings_copy(&imf->display_settings, &scene_src->display_settings); + BKE_color_managed_view_settings_copy(&imf->view_settings, &scene_src->view_settings); + BKE_color_managed_colorspace_settings_init(&imf->linear_colorspace_settings); +} |