GNU bug report logs - #15837
24.3; invalid colour conversion from Gtk+3 to X11

Previous Next

Package: emacs;

Reported by: Łukasz Stelmach <stlman <at> poczta.fm>

Date: Fri, 8 Nov 2013 18:29:01 UTC

Severity: normal

Tags: patch

Found in version 24.3

Done: Jan Djärv <jan.h.d <at> swipnet.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 15837 in the body.
You can then email your comments to 15837 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#15837; Package emacs. (Fri, 08 Nov 2013 18:29:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Łukasz Stelmach <stlman <at> poczta.fm>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 08 Nov 2013 18:29:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Łukasz Stelmach <stlman <at> poczta.fm>
To: bug-gnu-emacs <at> gnu.org 
Subject: 24.3; invalid colour conversion from Gtk+3 to X11
Date: Fri, 08 Nov 2013 19:16:18 +0100
Hello,

The function[1] that reads foreground and background colours from Gtk+3
(GdkRGBA) and converts them to X11 ones (XColor) uses improper
intermediate representation. The Gtk coulour is formated as
rgbi:<red>/<green>/<blue>. Although values prefixed with rgbi: are meant
to be floating point values like the ones returned by
gtk_style_context_get_*() functions but unlike Gtk colours they are
meant to be linear intensity values and will be gamma corrected[2] using
the tables[3] in Xlib.

You can check the effect for yourself by running:

xterm -bg '#777'
xterm -bg 'rgb:7777/7777/7777'
xterm -bg 'rgb:0.46667/0.46667/0.46667'

The last one will be significantly lighter.

0.46667/0.46667/0.46667 is the value returned by Gtk when a colour is
set to #777.

A patch will follow this report.

References:

[1] http://git.savannah.gnu.org/cgit/emacs.git/tree/src/gtkutil.c?id=c09a36ec78af479cb2ea39bf4bca8743cecd08df#n601

[2] http://cgit.freedesktop.org/xorg/doc/xorg-docs/tree/man/X.man?id=66e800c69fa5348b01e4b9670d6274ba392db7e5#n562

[3] http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/xcms/LRGB.c?id=6cb02b166361200da35ba14f52cd9aaa493eb0ea#n224
-- 
Było mi bardzo miło.                                  --- Rurku. --- ...
>Łukasz<                                --- To dobrze, że mnie słuchasz.

... Droga wśród jabłoni prowadzi w nieznane...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15837; Package emacs. (Fri, 08 Nov 2013 18:42:01 GMT) Full text and rfc822 format available.

Message #8 received at 15837 <at> debbugs.gnu.org (full text, mbox):

From: Łukasz Stelmach <stlman <at> poczta.fm>
To: 15837 <at> debbugs.gnu.org
Cc: Łukasz Stelmach <stlman <at> poczta.fm>
Subject: [PATCH] Pass colours using rgb: instead of rgbi:
Date: Fri,  8 Nov 2013 19:41:05 +0100
X procedures apply gamma correction to RGBi values which makes colours
obtained from Gtk+ 3.0 and displayed by Emacs look different than in
other Gtk applications.

Signed-off-by: Łukasz Stelmach <stlman <at> poczta.fm>
---
 src/gtkutil.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gtkutil.c b/src/gtkutil.c
index 7e304d4..b8d8610 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -596,14 +596,17 @@ xg_check_special_colors (struct frame *f,
     GtkStyleContext *gsty
       = gtk_widget_get_style_context (FRAME_GTK_OUTER_WIDGET (f));
     GdkRGBA col;
-    char buf[sizeof "rgbi://" + 3 * (DBL_MAX_10_EXP + sizeof "-1.000000" - 1)];
+    char buf[sizeof "rgb:rrrr/gggg/bbbb" ];
     int state = GTK_STATE_FLAG_SELECTED|GTK_STATE_FLAG_FOCUSED;
     if (get_fg)
       gtk_style_context_get_color (gsty, state, &col);
     else
       gtk_style_context_get_background_color (gsty, state, &col);
 
-    sprintf (buf, "rgbi:%lf/%lf/%lf", col.red, col.green, col.blue);
+    sprintf (buf, "rgb:%04x/%04x/%04x",
+             (int)(col.red * 65535),
+             (int)(col.green * 65535),
+             (int)(col.blue * 65535));
     success_p = (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
 			      buf, color)
 		 != 0);
-- 
1.8.1.5





Added tag(s) patch. Request was from Lukasz Stelmach <stlman <at> poczta.fm> to control <at> debbugs.gnu.org. (Fri, 08 Nov 2013 18:53:01 GMT) Full text and rfc822 format available.

Reply sent to Jan Djärv <jan.h.d <at> swipnet.se>:
You have taken responsibility. (Sat, 09 Nov 2013 11:22:01 GMT) Full text and rfc822 format available.

Notification sent to Łukasz Stelmach <stlman <at> poczta.fm>:
bug acknowledged by developer. (Sat, 09 Nov 2013 11:22:02 GMT) Full text and rfc822 format available.

Message #15 received at 15837-done <at> debbugs.gnu.org (full text, mbox):

From: Jan Djärv <jan.h.d <at> swipnet.se>
To: Łukasz Stelmach <stlman <at> poczta.fm>
Cc: 15837-done <at> debbugs.gnu.org
Subject: Re: bug#15837: [PATCH] Pass colours using rgb: instead of rgbi:
Date: Sat, 9 Nov 2013 12:20:57 +0100
Applied, thanks.

	Jan D.

8 nov 2013 kl. 19:41 skrev Łukasz Stelmach <stlman <at> poczta.fm>:

> X procedures apply gamma correction to RGBi values which makes colours
> obtained from Gtk+ 3.0 and displayed by Emacs look different than in
> other Gtk applications.
> 
> Signed-off-by: Łukasz Stelmach <stlman <at> poczta.fm>
> ---
> src/gtkutil.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gtkutil.c b/src/gtkutil.c
> index 7e304d4..b8d8610 100644
> --- a/src/gtkutil.c
> +++ b/src/gtkutil.c
> @@ -596,14 +596,17 @@ xg_check_special_colors (struct frame *f,
>     GtkStyleContext *gsty
>       = gtk_widget_get_style_context (FRAME_GTK_OUTER_WIDGET (f));
>     GdkRGBA col;
> -    char buf[sizeof "rgbi://" + 3 * (DBL_MAX_10_EXP + sizeof "-1.000000" - 1)];
> +    char buf[sizeof "rgb:rrrr/gggg/bbbb" ];
>     int state = GTK_STATE_FLAG_SELECTED|GTK_STATE_FLAG_FOCUSED;
>     if (get_fg)
>       gtk_style_context_get_color (gsty, state, &col);
>     else
>       gtk_style_context_get_background_color (gsty, state, &col);
> 
> -    sprintf (buf, "rgbi:%lf/%lf/%lf", col.red, col.green, col.blue);
> +    sprintf (buf, "rgb:%04x/%04x/%04x",
> +             (int)(col.red * 65535),
> +             (int)(col.green * 65535),
> +             (int)(col.blue * 65535));
>     success_p = (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
> 			      buf, color)
> 		 != 0);
> -- 
> 1.8.1.5
> 
> 
> 





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 07 Dec 2013 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 155 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.