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/makesrna | |
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/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_image_api.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 92e3254765c..55d365f9827 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -25,7 +25,9 @@ #ifdef RNA_RUNTIME # include "BKE_image.h" +# include "BKE_image_format.h" # include "BKE_main.h" +# include "BKE_scene.h" # include <errno.h> # include "IMB_colormanagement.h" @@ -68,19 +70,23 @@ static void rna_Image_save_render( else { ImBuf *write_ibuf; - write_ibuf = IMB_colormanagement_imbuf_for_write( - ibuf, true, true, &scene->view_settings, &scene->display_settings, &scene->r.im_format); + ImageFormatData image_format; + BKE_image_format_init_for_write(&image_format, scene, NULL); - write_ibuf->planes = scene->r.im_format.planes; + write_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, true, true, &image_format); + + write_ibuf->planes = image_format.planes; write_ibuf->dither = scene->r.dither_intensity; - if (!BKE_imbuf_write(write_ibuf, path, &scene->r.im_format)) { + if (!BKE_imbuf_write(write_ibuf, path, &image_format)) { BKE_reportf(reports, RPT_ERROR, "Could not write image: %s, '%s'", strerror(errno), path); } if (write_ibuf != ibuf) { IMB_freeImBuf(write_ibuf); } + + BKE_image_format_free(&image_format); } BKE_image_release_ibuf(image, ibuf, lock); |