- Use absolute value of the color difference when calculating color match rating.

svn path=/trunk/; revision=9996
This commit is contained in:
Filip Navara 2004-07-04 17:09:45 +00:00
parent dd64375195
commit 91008697a8
2 changed files with 8 additions and 8 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: xlate.c,v 1.39 2004/07/03 13:55:35 navaraf Exp $
/* $Id: xlate.c,v 1.40 2004/07/04 17:09:45 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -64,11 +64,11 @@ ClosestColorMatch(XLATEGDI *XlateGDI, LPPALETTEENTRY SourceColor,
for (CurrentIndex = 0; CurrentIndex < NumColors; CurrentIndex++)
{
cxRed = (SourceRed - DestColors[CurrentIndex].peRed);
cxRed = abs((SHORT)SourceRed - (SHORT)DestColors[CurrentIndex].peRed);
cxRed *= cxRed;
cxGreen = (SourceGreen - DestColors[CurrentIndex].peGreen);
cxGreen = abs((SHORT)SourceGreen - (SHORT)DestColors[CurrentIndex].peGreen);
cxGreen *= cxGreen;
cxBlue = (SourceBlue - DestColors[CurrentIndex].peBlue);
cxBlue = abs((SHORT)SourceBlue - (SHORT)DestColors[CurrentIndex].peBlue);
cxBlue *= cxBlue;
Rating = cxRed + cxGreen + cxBlue;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: color.c,v 1.48 2004/07/03 17:40:27 navaraf Exp $ */
/* $Id: color.c,v 1.49 2004/07/04 17:09:45 navaraf Exp $ */
#include <w32k.h>
// FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping
@ -550,9 +550,9 @@ INT STDCALL COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size,
continue;
#endif
r = palPalEntry[i].peRed - GetRValue(col);
g = palPalEntry[i].peGreen - GetGValue(col);
b = palPalEntry[i].peBlue - GetBValue(col);
r = abs((SHORT)palPalEntry[i].peRed - GetRValue(col));
g = abs((SHORT)palPalEntry[i].peGreen - GetGValue(col));
b = abs((SHORT)palPalEntry[i].peBlue - GetBValue(col));
r = r*r + g*g + b*b;