Re: [gtk-list] Re: how to convert windows RGB color to GdkColor
- From: Rick L Vinyard Jr <vinyard zianet com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: how to convert windows RGB color to GdkColor
- Date: Wed, 01 Sep 1999 04:51:57 +0000
"Timothy M. Shead" wrote:
> > This is not enough. You then need to add the original value. I.e.
> > new_value = (old_value << 8) + old_value;
> > Assuming old_value is in [0, 255].
> > I thought I understood gdkcolors until now. I have always been under
> > the impression that a gdkcolor simply uses a 16-bit value for each of
> > red, green, and blue, and that it was converted for whatever hardware
> > you were to run on by dividing (so, to run on something with 8-bit
> > DACs, you'd right-shift by (16-8) == 8).
> Right-shifting to convert from 16bpp to 8bpp works fine:
> 0xFFFF (full-bright) becomes 0xFF (full-bright).
> But left-shifting doesn't:
> 0xFF (full-bright) becomes 0xFF00 (less-than-full-bright).
> Adding in the old value is a fast way to scale the values properly, so 0xFF
> becomes 0xFFFF. You can multiply by 257.0 if you prefer :)
Well stated. And by gradually shifting through the range, you end up
with a more balanced spectrum of intensities, rather than shifting to a
brighter intensity like I stated earlier. I had forgotten about that
when I replied earlier, and was too focused on data structures.
Rick L. Vinyard, Jr.
] [Thread Prev