From 0d38f21cbc004a2aa8b4a944aaf068d83e75a197 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 14 Apr 2014 13:45:09 +0600 Subject: Fix the eyedropper not working properly with different scene linear spaces Either was some residue from the past or somebody didn't implement this in the right way. Also fixed memory leak in ED_space_clip_color_sample() caused by missing image buffer release. --- source/blender/editors/space_clip/clip_editor.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/space_clip/clip_editor.c') diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index f3938c2aebe..7b8d659d857 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -260,10 +260,11 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale return NULL; } -/* returns color in SRGB */ -/* matching ED_space_image_color_sample() */ -bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r_col[3]) +/* Returns color in the display space, matching ED_space_image_color_sample(). */ +bool ED_space_clip_color_sample(Scene *scene, SpaceClip *sc, ARegion *ar, int mval[2], float r_col[3]) { + const char *display_device = scene->display_settings.display_device; + struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device); ImBuf *ibuf; float fx, fy, co[2]; bool ret = false; @@ -289,16 +290,22 @@ bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); - linearrgb_to_srgb_v3_v3(r_col, fp); + copy_v3_v3(r_col, fp); ret = true; } else if (ibuf->rect) { cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); - rgb_uchar_to_float(r_col, cp); + IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace); ret = true; } } + if (ret) { + IMB_colormanagement_scene_linear_to_display_v3(r_col, display); + } + + IMB_freeImBuf(ibuf); + return ret; } -- cgit v1.2.3