diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-14 11:45:09 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-14 11:48:20 +0400 |
commit | 0d38f21cbc004a2aa8b4a944aaf068d83e75a197 (patch) | |
tree | bd31c2e765e962acb0071bf8b964fa19e4c1b660 /source/blender/editors/space_node/node_view.c | |
parent | f24bfcffefa0eca74dbfb26f1e331c3f7a7da85e (diff) |
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.
Diffstat (limited to 'source/blender/editors/space_node/node_view.c')
-rw-r--r-- | source/blender/editors/space_node/node_view.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index 8946b38653f..24aa6fa8cbe 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -417,10 +417,13 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) } } -/* returns color in SRGB */ -/* matching ED_space_image_color_sample() */ -bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float r_col[3]) +/* Returns color in the display space, matching ED_space_image_color_sample(). + * And here we've got recursion in the comments tips... + */ +bool ED_space_node_color_sample(Scene *scene, SpaceNode *snode, 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); void *lock; Image *ima; ImBuf *ibuf; @@ -457,16 +460,20 @@ bool ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], floa if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); /* IB_PROFILE_NONE is default but infact its linear */ - 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); + } + BKE_image_release_ibuf(ima, ibuf, lock); return ret; |