Module: wine Branch: master Commit: cca639fa641f01f42840042f17c1499785562f17 URL: https://source.winehq.org/git/wine.git/?a=commit;h=cca639fa641f01f42840042f1...
Author: Jacek Caban jacek@codeweavers.com Date: Wed May 27 23:55:18 2020 +0200
gdiplus: Introduce absdiff helper.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Esme Povirk vincent@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/gdiplus/image.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index cafe69d8f4..39f717b5b3 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -380,6 +380,11 @@ GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y, return Ok; }
+static unsigned int absdiff(unsigned int x, unsigned int y) +{ + return x > y ? x - y : y - x; +} + static inline UINT get_palette_index(BYTE r, BYTE g, BYTE b, BYTE a, ColorPalette *palette) { BYTE index = 0; @@ -399,7 +404,7 @@ static inline UINT get_palette_index(BYTE r, BYTE g, BYTE b, BYTE a, ColorPalett */ for(i=0;i<palette->Count;i++) { ARGB color=palette->Entries[i]; - distance=abs(b-(color & 0xff)) + abs(g-(color>>8 & 0xff)) + abs(r-(color>>16 & 0xff)) + abs(a-(color>>24 & 0xff)); + distance=absdiff(b, color & 0xff) + absdiff(g, color>>8 & 0xff) + absdiff(r, color>>16 & 0xff) + absdiff(a, color>>24 & 0xff); if (distance<best_distance) { best_distance=distance; index=i;