From cd7fbb8e5c6af936fcc8cc4122061b9b2b4df0f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Sun, 14 Mar 2004 00:11:28 +0000 Subject: [PATCH] Translate pixel value from internal pixel format to RGB. Fixes bug #251. svn path=/trunk/; revision=8697 --- reactos/subsys/win32k/objects/bitmaps.c | 33 ++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/reactos/subsys/win32k/objects/bitmaps.c b/reactos/subsys/win32k/objects/bitmaps.c index a6363ab909d..5eb5d2a8ccb 100644 --- a/reactos/subsys/win32k/objects/bitmaps.c +++ b/reactos/subsys/win32k/objects/bitmaps.c @@ -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: bitmaps.c,v 1.60 2004/03/10 16:55:03 navaraf Exp $ */ +/* $Id: bitmaps.c,v 1.61 2004/03/14 00:11:28 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -458,6 +458,10 @@ COLORREF STDCALL NtGdiGetPixel(HDC hDC, INT XPos, INT YPos) COLORREF Result = (COLORREF) 0; PSURFGDI Surface; PSURFOBJ SurfaceObject; + HPALETTE Pal; + PPALGDI PalGDI; + USHORT PalMode; + PXLATEOBJ XlateObj = NULL; dc = DC_LockDc (hDC); if (dc == NULL) @@ -480,6 +484,33 @@ COLORREF STDCALL NtGdiGetPixel(HDC hDC, INT XPos, INT YPos) return (COLORREF)CLR_INVALID; } Result = Surface->DIB_GetPixel(SurfaceObject, XPos, YPos); + + if (dc->w.hPalette != 0) + { + Pal = dc->w.hPalette; + } + else + { + Pal = NtGdiGetStockObject(DEFAULT_PALETTE); + } + PalGDI = PALETTE_LockPalette(Pal); + if (NULL == PalGDI) + { + DC_UnlockDc(hDC); + return (COLORREF)CLR_INVALID; + } + PalMode = PalGDI->Mode; + PALETTE_UnlockPalette(Pal); + + XlateObj = (PXLATEOBJ) IntEngCreateXlate(PAL_RGB, PalMode, NULL, Pal); + if (NULL == XlateObj) + { + DC_UnlockDc(hDC); + return (COLORREF)CLR_INVALID; + } + Result = XLATEOBJ_iXlate(XlateObj, Result); + EngDeleteXlate(XlateObj); + DC_UnlockDc(hDC); return Result; }