Module: wine Branch: master Commit: 38e06bfbe343abd8227dd2be227325290c77e42b URL: https://gitlab.winehq.org/wine/wine/-/commit/38e06bfbe343abd8227dd2be2273252...
Author: Piotr Caban piotr@codeweavers.com Date: Thu Dec 7 11:42:22 2023 +0100
wineps: Fix color handling in PSDRV_WriteDIBPatternDict.
---
dlls/wineps.drv/ps.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 2a3da737c81..03c92aa00f0 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -1002,8 +1002,34 @@ BOOL PSDRV_WriteDIBPatternDict(print_ctx *ctx, const BITMAPINFO *bmi, BYTE *bits PSDRV_WriteSpool(ctx, "def\n", 4);
PSDRV_WriteIndexColorSpaceBegin(ctx, 1); - map[0] = GetTextColor( ctx->hdc ); - map[1] = GetBkColor( ctx->hdc ); + if (usage == DIB_RGB_COLORS) + { + map[0] = RGB( bmi->bmiColors[0].rgbRed, bmi->bmiColors[0].rgbGreen, + bmi->bmiColors[0].rgbBlue ); + map[1] = RGB( bmi->bmiColors[1].rgbRed, bmi->bmiColors[1].rgbGreen, + bmi->bmiColors[1].rgbBlue ); + } + else if (usage == DIB_PAL_COLORS) + { + HPALETTE hpal = GetCurrentObject( ctx->hdc, OBJ_PAL ); + PALETTEENTRY pal[2]; + + memset(pal, 0, sizeof(pal)); + if (hpal) GetPaletteEntries(hpal, 0, 2, pal); + + map[0] = RGB(pal[0].peRed, pal[0].peGreen, pal[0].peBlue); + map[1] = RGB(pal[1].peRed, pal[1].peGreen, pal[1].peBlue); + } + else if (usage == 2 /* DIB_PAL_INDICES */) + { + map[0] = GetTextColor( ctx->hdc ); + map[1] = GetBkColor( ctx->hdc ); + } + else + { + FIXME("wrong usage: %d\n", usage); + return FALSE; + } PSDRV_WriteRGB(ctx, map, 2); PSDRV_WriteIndexColorSpaceEnd(ctx);