From dce4aa48ee2b710aa9a7de6fc2f232c7d19e59f9 Mon Sep 17 00:00:00 2001 From: hobbs Date: Thu, 2 Mar 2000 23:53:26 +0000 Subject: * tests/color.test: * xlib/xcolors.c (XParseColor FindColor): * win/tkWinColor.c (XAllocColor): Fixed bit fiddling for colors to return "correct" values for color mapping. [Bug: 4282] --- xlib/xcolors.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/xlib/xcolors.c b/xlib/xcolors.c index bc15d42..f345e08 100644 --- a/xlib/xcolors.c +++ b/xlib/xcolors.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: xcolors.c,v 1.2 1998/09/14 18:24:02 stanton Exp $ + * RCS: @(#) $Id: xcolors.c,v 1.3 2000/03/02 23:53:26 hobbs Exp $ */ #include @@ -854,9 +854,9 @@ FindColor(name, colorPtr) if (l > u) { return 0; } - colorPtr->red = xColors[i].red << 8; - colorPtr->green = xColors[i].green << 8; - colorPtr->blue = xColors[i].blue << 8; + colorPtr->red = ((xColors[i].red << 8) | xColors[i].red); + colorPtr->green = ((xColors[i].green << 8) | xColors[i].green); + colorPtr->blue = ((xColors[i].blue << 8) | xColors[i].blue); return 1; } @@ -896,9 +896,12 @@ XParseColor(display, map, spec, colorPtr) if (sscanf(spec+1, fmt, &red, &green, &blue) != 3) { return 0; } - colorPtr->red = ((unsigned short) red) << (4 * (4 - i)); - colorPtr->green = ((unsigned short) green) << (4 * (4 - i)); - colorPtr->blue = ((unsigned short) blue) << (4 * (4 - i)); + colorPtr->red = (((unsigned short) red) << (4 * (4 - i))) + | ((unsigned short) red); + colorPtr->green = (((unsigned short) green) << (4 * (4 - i))) + | ((unsigned short) green); + colorPtr->blue = (((unsigned short) blue) << (4 * (4 - i))) + | ((unsigned short) blue); } else { if (!FindColor(spec, colorPtr)) { return 0; -- cgit v0.12