- In NtGdiSetPixel, return the real RGB value, which is the target format color translated back to RGB, not the desired RGB value. Fixes a few bitmap winetest.
- Handle a too large index in PALETTE_ulGetRGBColorFromIndex

svn path=/trunk/; revision=56439
This commit is contained in:
Timo Kreuzer 2012-04-27 16:46:12 +00:00
parent e5491506f1
commit d926eda7ce
2 changed files with 19 additions and 13 deletions

View file

@ -37,7 +37,6 @@ TranslateCOLORREF(PDC pdc, COLORREF *pcrColor)
/* Get the RGB value */ /* Get the RGB value */
crColor = PALETTE_ulGetRGBColorFromIndex(ppalDC, index); crColor = PALETTE_ulGetRGBColorFromIndex(ppalDC, index);
*pcrColor = crColor;
break; break;
case 0x02: /* PALETTERGB */ case 0x02: /* PALETTERGB */
@ -48,7 +47,6 @@ TranslateCOLORREF(PDC pdc, COLORREF *pcrColor)
/* Get the RGB value */ /* Get the RGB value */
crColor = PALETTE_ulGetRGBColorFromIndex(ppalDC, index); crColor = PALETTE_ulGetRGBColorFromIndex(ppalDC, index);
*pcrColor = crColor;
break; break;
case 0x10: /* DIBINDEX */ case 0x10: /* DIBINDEX */
@ -62,10 +60,7 @@ TranslateCOLORREF(PDC pdc, COLORREF *pcrColor)
/* Translate the color to RGB for the caller */ /* Translate the color to RGB for the caller */
ppalSurface = pdc->dclevel.pSurface->ppal; ppalSurface = pdc->dclevel.pSurface->ppal;
if (index < ppalSurface->NumColors)
*pcrColor = PALETTE_ulGetRGBColorFromIndex(ppalSurface, index); *pcrColor = PALETTE_ulGetRGBColorFromIndex(ppalSurface, index);
else
*pcrColor = 0;
return index; return index;
default: default:
@ -74,17 +69,27 @@ TranslateCOLORREF(PDC pdc, COLORREF *pcrColor)
} }
/* Initialize an XLATEOBJ from RGB to the target surface */ /* Initialize an XLATEOBJ from RGB to the target surface */
EXLATEOBJ_vInitialize(&exlo, ppalSurface = pdc->dclevel.pSurface->ppal;
&gpalRGB, EXLATEOBJ_vInitialize(&exlo, &gpalRGB, ppalSurface, 0xFFFFFF, 0, 0);
pdc->dclevel.pSurface->ppal,
0,
pdc->pdcattr->crBackgroundClr,
pdc->pdcattr->crForegroundClr);
/* Translate the color to the target format */ /* Translate the color to the target format */
ulColor = XLATEOBJ_iXlate(&exlo.xlo, crColor); ulColor = XLATEOBJ_iXlate(&exlo.xlo, crColor);
/* Cleanup and return the RGB value */ /* Cleanup the XLATEOBJ */
EXLATEOBJ_vCleanup(&exlo);
/* Initialize an XLATEOBJ from the target surface to RGB */
EXLATEOBJ_vInitialize(&exlo,
ppalSurface,
&gpalRGB,
0,
pdc->pdcattr->crBackgroundClr,
pdc->pdcattr->crForegroundClr);
/* Translate the color back to RGB */
*pcrColor = XLATEOBJ_iXlate(&exlo.xlo, ulColor);
/* Cleanup and return the target format color */
EXLATEOBJ_vCleanup(&exlo); EXLATEOBJ_vCleanup(&exlo);
return ulColor; return ulColor;
} }

View file

@ -100,6 +100,7 @@ FORCEINLINE
ULONG ULONG
PALETTE_ulGetRGBColorFromIndex(PPALETTE ppal, ULONG ulIndex) PALETTE_ulGetRGBColorFromIndex(PPALETTE ppal, ULONG ulIndex)
{ {
if (ulIndex >= ppal->NumColors) return 0;
return RGB(ppal->IndexedColors[ulIndex].peRed, return RGB(ppal->IndexedColors[ulIndex].peRed,
ppal->IndexedColors[ulIndex].peGreen, ppal->IndexedColors[ulIndex].peGreen,
ppal->IndexedColors[ulIndex].peBlue); ppal->IndexedColors[ulIndex].peBlue);