From cbbca1e98f205eb620418c8c3b55995ef3f1217e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 8 Dec 2025 20:16:20 +0200 Subject: [PATCH] [WIN32K:NTGDI] Improve NtGdiSetPixel --- win32ss/gdi/ntgdi/bitblt.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/win32ss/gdi/ntgdi/bitblt.c b/win32ss/gdi/ntgdi/bitblt.c index 2462cef83a8..6c842299482 100644 --- a/win32ss/gdi/ntgdi/bitblt.c +++ b/win32ss/gdi/ntgdi/bitblt.c @@ -1443,8 +1443,7 @@ NtGdiSetPixel( pdc = DC_LockDc(hdc); if (!pdc) { - EngSetLastError(ERROR_INVALID_HANDLE); - return -1; + return CLR_INVALID; } /* Check if the DC has no surface (empty mem or info DC) */ @@ -1452,7 +1451,7 @@ NtGdiSetPixel( { /* Fail! */ DC_UnlockDc(pdc); - return -1; + return CLR_INVALID; } if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR)) @@ -1492,13 +1491,13 @@ NtGdiSetPixel( pdc->pdcattr->ulDirty_ = ulDirty; /// FIXME: we shouldn't dereference pSurface while the PDEV is not locked! - /* Initialize an XLATEOBJ from the target surface to RGB */ + /* Initialize an XLATEOBJ from the target surface to RGB without using BkColor */ EXLATEOBJ_vInitialize(&exlo, pdc->dclevel.pSurface->ppal, &gpalRGB, - 0, - pdc->pdcattr->crBackgroundClr, - pdc->pdcattr->crForegroundClr); + CLR_INVALID, + CLR_INVALID, + CLR_INVALID); /* Translate the color back to RGB */ crColor = XLATEOBJ_iXlate(&exlo.xlo, iSolidColor); @@ -1509,8 +1508,8 @@ NtGdiSetPixel( /* Unlock the DC */ DC_UnlockDc(pdc); - /* Return the new RGB color or -1 on failure */ - return bResult ? crColor : -1; + /* Return the new RGB color or CLR_INVALID (-1) on failure */ + return bResult ? crColor : CLR_INVALID; } COLORREF @@ -1583,13 +1582,13 @@ NtGdiGetPixel( RECTL rclDest = {0, 0, 1, 1}; EXLATEOBJ exlo; - /* Translate from the source palette to RGB color */ + /* Translate from the source palette to RGB color without BkColor */ EXLATEOBJ_vInitialize(&exlo, psurfSrc->ppal, &gpalRGB, - 0, - RGB(0xff,0xff,0xff), - RGB(0,0,0)); + CLR_INVALID, + CLR_INVALID, + CLR_INVALID); /* Call the copy bits function */ EngCopyBits(&psurfDest->SurfObj,