On 27.05.2010, at 11:05, MacArthur, Ian (SELEX GALILEO, UK) wrote:

> The fltk code seems to test for this by masking the colour value with
> 0xffffff00 and if that is non-zero, it treats it as RGB.
>
> If that is zero, it masks with 0x000000FF and then looks up the related
> RGB values by doing a lookup into fl_cmap[] array.
>
> (pseudo code...)
>
>       int i = c&  0x000000ff;
>       unsigned rgb = fl_cmap[i];
>       r = rgb>>  24;
>       g = rgb>>  16;
>       b = rgb>>  8;
>
> (e.g. see fl_color_win32.cxx etc near line 111 of fltk-1.3)
>
> The problem with this seems to be that the fl_cmap[] array is static,
> and I don't see how we get access to those values easily...
>
> Anybody know how that's done?

Not directly, but this trick should do it:

  unsigned rgb = (unsigned)fl_color_average((Fl_Color)i, FL_WHITE, 1.0);

  r = rgb>>  24 & 255;
  g = rgb>>  16 & 255;
  b = rgb>>   8 & 255;

i can be any color (index or RGB value).
FL_WHITE can be replaced with any color.

Disclaimer: untested code!

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to