From fd22a5603ab11cc2c332a98220e98081964a9eeb Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 30 Aug 2012 17:55:21 +0000 Subject: Fix #32418: color copy/paste between gamma and linear color buttons gave wrong results, now it does the conversion. --- source/blender/editors/interface/interface_handlers.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ca52daa8cd2..31bc40326c2 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1187,12 +1187,20 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, else if (mode == 'c') { ui_get_but_vectorf(but, rgb); + /* convert to linear color to do compatible copy between gamma and non-gamma */ + if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) + srgb_to_linearrgb_v3_v3(rgb, rgb); + BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f]", rgb[0], rgb[1], rgb[2]); WM_clipboard_text_set(buf, 0); } else { if (sscanf(buf, "[%f, %f, %f]", &rgb[0], &rgb[1], &rgb[2]) == 3) { + /* assume linear colors in buffer */ + if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) + linearrgb_to_srgb_v3_v3(rgb, rgb); + button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); ui_set_but_vectorf(but, rgb); button_activate_state(C, but, BUTTON_STATE_EXIT); -- cgit v1.2.3