On Wed, Aug 13, 2003 at 09:47:38AM +0100, Angus Leeming spake thusly:
 
> Martin Vermeer wrote:
> 
> > OK to commit?
> 
> I wasn't paying too much attention to your earlier explanation. Thw 
> code below looks entirely reasonable. Why do you want to get rid of 
> the 'XAllocColor(... &ccol)' step?
> 
>         if (XLookupColor(display, colormap, s.c_str(), &xcol, &ccol) == 0) {
>                 unsigned long bla = BlackPixel(display,
>                                                DefaultScreen(display));
>                 val.foreground = bla;
>         // Try the exact RGB values first, then the approximate.
>         } else if (XAllocColor(display, colormap, &xcol) != 0) {
>                 val.foreground = xcol.pixel;
> -       } else if (XAllocColor(display, colormap, &ccol)) {
> -               val.foreground = xcol.pixel;
>         } else {
>                 // Here we are traversing the current colormap to find
>                 // the color closest to the one we want.
>                 val.foreground = cmap[closest_pixel].pixel;
>         }
> 
> -- 
> Angus

Because I don't think it does anything. As I understand it, the first 
XAllocColor call will, if it succeeds, return ccol -- the nearest 
colour the hardware can display -- in its xcol parameter. In that case
the second one will not produce any different value.

And if the first call fails, so will the second (I think from reading
the docs as well as I could :-( )

Martin

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to