Re: Getting hex string from a GdkColor



On Friday 08 April 2005 17:06, Stefano Esposito wrote:

> i've a color button from which i obtain a GdkColor with
> gtk_color_button_get_color(). Now i need the hex string representing this
> color but all that i find searching in the api docs is a function that
> obtain a GdkColor from an hex string. Any hints? Thanks to you all :)

Maybe something like:

GdkColor  c;
gchar *s;

gdk_color_parse ("DarkRed", &c);
s = g_strdup_printf ("%02x%02x%02x", 
                                c.red >> 8, 
                                c.green >> 8, 
                                c.blue >> 8);

or

gdk_color_parse ("DarkRed", &c);
s = g_strdup_printf ("%04x%04x%04x", c.red, c.green, c.blue);

Cheers
 -Tim



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]