From c183b86b8a3aed00ab7225fd8478fa3ff0ebb5f5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 5 May 2012 22:50:47 +0000 Subject: [PATCH] [WIN32K] Fix regression of gdi32_winetest palette svn path=/trunk/; revision=56521 --- reactos/win32ss/gdi/ntgdi/dibobj.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/reactos/win32ss/gdi/ntgdi/dibobj.c b/reactos/win32ss/gdi/ntgdi/dibobj.c index 78eb3d8f04d..b755dc3ae25 100644 --- a/reactos/win32ss/gdi/ntgdi/dibobj.c +++ b/reactos/win32ss/gdi/ntgdi/dibobj.c @@ -148,9 +148,12 @@ CreateDIBPalette( /* Loop all color indices in the DIB */ for (i = 0; i < cColors; i++) { - /* Get the RGB value from the DC palette, indexed by the DIB - color table value */ - crColor = PALETTE_ulGetRGBColorFromIndex(ppalDC, pwColors[i]); + /* Get the palette index and handle wraparound when exceeding + the number of colors in the DC palette */ + WORD wIndex = pwColors[i] % ppalDC->NumColors; + + /* USe the RGB value from the DC palette */ + crColor = PALETTE_ulGetRGBColorFromIndex(ppalDC, wIndex); PALETTE_vSetRGBColorForIndex(ppal, i, crColor); } }