Re: GdkColor



On Mon, 2003-02-10 at 22:31, James Drabb wrote:
> On Mon, 10 Feb 2003 21:58:09 -0500
> James Drabb <JDrabb tampabay rr com> wrote:
> 
> > Hello group,
> > 
> > I just started switching to Linux development with GTK
> > from Visual C++ (ewww).  Anyway, I am bringing up a
> > color selection dialog with gtk_color_selection_dialog_new.
> > Now a user selects thier color and I retrieve that
> > with a call to gtk_color_selection_get_current_color.
> > Now I have a GdkColor variable named color with the
> > red, green and blue components.  However, say I selected full
> > red and no green or blue, the red member has a value of 65535. What do
> > I need to do to convert the red, green and blue into an RGB?  I
> > want to end up with something like R=>255, G=>128, B=>0.
> > 
> > Thanks for any help,
> > 
> > Jim Drabb
> 
> Never mind.  Sorry for the dumb question!
> 
>   (color.red & 0xff)

Actually, try 

 color.red >> 8 

instead. Basically you want to convert a color in the range of 
0-65535 to 0-255, and dividing by 256 is the correct way to do
this.

Regards,
                                     Owen




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