RE: [gtk-list] Re: how to convert windows RGB color to GdkColor
- From: "Timothy M. Shead" <tshead sheaddataproc com>
- To: <gtk-list redhat com>
- Subject: RE: [gtk-list] Re: how to convert windows RGB color to GdkColor
- Date: Tue, 31 Aug 1999 19:30:01 -0700
> 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 :)
Go Lobos!
Tim
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]