[WIN32K:NTGDI] Fix pen color on 1BPP surfaces

The actual color is not nearest-matched (like for SetPixel), but the RGB color is matched against background color of the DC.
This commit is contained in:
Timo Kreuzer
2025-12-09 14:18:59 +02:00
parent f09fcc2a96
commit ece903d96f
2 changed files with 36 additions and 14 deletions

View File

@@ -132,20 +132,42 @@ EBRUSHOBJ_vSetSolidRGBColor(EBRUSHOBJ *pebo, COLORREF crColor)
pebo->crRealize = crColor;
pebo->ulRGBColor = crColor;
/* Initialize an XLATEOBJ RGB -> surface */
EXLATEOBJ_vInitialize(&exlo,
&gpalRGB,
pebo->ppalSurf,
pebo->crCurrentBack,
0,
0);
/* Special handling for mono-surfaces */
if (pebo->ppalSurf->flFlags & PAL_MONOCHROME)
{
/* Determine the indices for back and fore color */
ULONG iBackIndex =
PALETTE_ulGetNearestPaletteIndex(pebo->ppalSurf, pebo->crCurrentBack);
ULONG iForeIndex = iBackIndex ^ 1;
/* Translate the brush color to the target format */
iSolidColor = XLATEOBJ_iXlate(&exlo.xlo, crColor);
pebo->BrushObject.iSolidColor = iSolidColor;
/* Get the translated back color */
ULONG rgbBack = PALETTE_ulGetRGBColorFromIndex(pebo->ppalSurf, iBackIndex);
/* Clean up the XLATEOBJ */
EXLATEOBJ_vCleanup(&exlo);
/* Match the pen color against RGB and translated background color */
if ((crColor == rgbBack) || (crColor == pebo->crCurrentBack))
pebo->BrushObject.iSolidColor = iBackIndex;
else
pebo->BrushObject.iSolidColor = iForeIndex;
pebo->flattrs |= BR_NEED_BK_CLR;
}
else
{
/* Initialize an XLATEOBJ RGB -> surface */
EXLATEOBJ_vInitialize(&exlo,
&gpalRGB,
pebo->ppalSurf,
pebo->crCurrentBack,
0,
0);
/* Translate the brush color to the target format */
iSolidColor = XLATEOBJ_iXlate(&exlo.xlo, crColor);
pebo->BrushObject.iSolidColor = iSolidColor;
/* Clean up the XLATEOBJ */
EXLATEOBJ_vCleanup(&exlo);
}
}
VOID

View File

@@ -80,8 +80,8 @@ typedef struct _EBRUSHOBJ
COLORADJUSTMENT *pca;
// DWORD dwUnknown2c;
// DWORD dwUnknown30;
SURFACE * psurfTrg;
struct _PALETTE * ppalSurf;
_Notnull_ SURFACE * psurfTrg;
_Notnull_ struct _PALETTE * ppalSurf;
struct _PALETTE * ppalDC;
struct _PALETTE * ppalDIB;
// DWORD dwUnknown44;