diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-09-24 15:56:07 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-09-24 15:56:07 +0400 |
commit | 9e3e12fa4e2b9038314e3f2f690a908042b835fa (patch) | |
tree | 4f5178f7e7ff7b8ff6a6ebd74459621f146adaf2 /source/blender/editors/space_image | |
parent | 5a5b37a4fadee5ce2c44b097a50986e0b70ca898 (diff) |
Proper fix for #32626: TIFF renders are limited to 8 bit even when we choose 16.
Color management would be applied on both of float and byte buffers on image
save in cases if file format doesn't require linear float buffer and if image
is saving as render result.
This solves both initial report issue and TODO marked in previous fix.
Also de-duplicated image buffer color managing code and gave some more
meaningful names for few functions. Also wrote documentation around this
function, so current assumptions about spaces should be clear enough.
Made regression tests by saving EXR/PNG images to all supported format and
rendering OpenGL/Normal animation, in all cases seems everything is fine,
but more tests for sure would be welcome.
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 43 |
2 files changed, 4 insertions, 41 deletions
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 0b904f36a8c..59416dcf0c3 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -814,7 +814,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man /* color management */ if (color_management && - (!BKE_imtype_supports_float(imf->imtype) || + (!BKE_imtype_requires_linear_float(imf->imtype) || (show_preview && imf->flag & R_IMF_FLAG_PREVIEW_JPG))) { prop = RNA_struct_find_property(imfptr, "display_settings"); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 16c9405e098..cfb265433a9 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1205,39 +1205,6 @@ static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op) RNA_string_set(op->ptr, "filepath", simopts->filepath); } -static ImBuf *save_image_colormanaged_imbuf_acquire(ImBuf *ibuf, SaveImageOptions *simopts, int save_as_render, void **cache_handle) -{ - ImageFormatData *imf = &simopts->im_format; - ImBuf *colormanaged_ibuf; - int do_colormanagement; - - *cache_handle = NULL; - do_colormanagement = save_as_render && !BKE_imtype_supports_float(imf->imtype); - - if (do_colormanagement) { - unsigned char *display_buffer; - - display_buffer = IMB_display_buffer_acquire(ibuf, &imf->view_settings, &imf->display_settings, cache_handle); - - if (*cache_handle) { - colormanaged_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0); - colormanaged_ibuf->rect = (unsigned int *) display_buffer; - } - else { - /* no cache handle means color management didn't run transformation - * or performed transformation to image's byte buffer which doesn't - * require allocating new image buffer - */ - colormanaged_ibuf = ibuf; - } - } - else { - colormanaged_ibuf = ibuf; - } - - return colormanaged_ibuf; -} - /* assumes name is FILE_MAX */ /* ima->name and ibuf->name should end up the same */ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath) @@ -1247,12 +1214,12 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); if (ibuf) { - void *cache_handle; ImBuf *colormanaged_ibuf; const char *relbase = ID_BLEND_PATH(CTX_data_main(C), &ima->id); const short relative = (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path")); const short save_copy = (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy")); const short save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") && RNA_boolean_get(op->ptr, "save_as_render")); + ImageFormatData *imf = &simopts->im_format; short ok = FALSE; /* old global to ensure a 2nd save goes to same dir */ @@ -1277,7 +1244,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI } } - colormanaged_ibuf = save_image_colormanaged_imbuf_acquire(ibuf, simopts, save_as_render, &cache_handle); + colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, save_as_render, TRUE, &imf->view_settings, &imf->display_settings, imf); if (simopts->im_format.imtype == R_IMF_IMTYPE_MULTILAYER) { Scene *scene = CTX_data_scene(C); @@ -1345,12 +1312,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI WM_cursor_wait(0); - if (cache_handle) { - colormanaged_ibuf->rect = NULL; + if (colormanaged_ibuf != ibuf) IMB_freeImBuf(colormanaged_ibuf); - - IMB_display_buffer_release(cache_handle); - } } ED_space_image_release_buffer(sima, lock); |