[PATCH 0/1] MR8988: win32u: change the stretch mode of dst hdc from BlackOnWhite to ColorOnColor...
win32u: change the stretch mode of dst hdc from BlackOnWhite to ColorOnColor when using StretchBlt in TransparentBlt. In NtGdiTransparentBlt function, the StretchBlt mode of dst hdc is not set. The Default StretchBlt Mode in wine is BlackOnWhite. It is not correct to use this StretchBltMode in TransparentBlt dealing with color bitmap. According to MSDN, it should be converted to ColorOnColor. My test code shows that, the image converted by wine generates a lot of chromatic noise. [test_blt.c](/uploads/26101bc7bdb27400d02c8ff5bf741864/test_blt.c) [test_blt.exe](/uploads/98ee3ab7ce0d590e1511bd8a5fb5a1bb/test_blt.exe)    -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8988
From: yangkun <yangkun(a)uniontech.com> Signed-off-by: yangkun <yangkun(a)uniontech.com> Change-Id: Ic3c64a5d2ffef7d890f461b089223fbd7a972ffd --- dlls/win32u/bitblt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/win32u/bitblt.c b/dlls/win32u/bitblt.c index a9f6f70daf6..96342dfa6db 100644 --- a/dlls/win32u/bitblt.c +++ b/dlls/win32u/bitblt.c @@ -857,6 +857,7 @@ BOOL WINAPI NtGdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDes int oldStretchMode; DIBSECTION dib; DC *dc_src; + DC *dc_work; if(widthDest < 0 || heightDest < 0 || widthSrc < 0 || heightSrc < 0) { TRACE("Cannot mirror\n"); @@ -890,6 +891,10 @@ BOOL WINAPI NtGdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDes } else bmpWork = NtGdiCreateCompatibleBitmap( hdcDest, widthDest, heightDest ); oldWork = NtGdiSelectBitmap(hdcWork, bmpWork); + + if (!(dc_work = get_dc_ptr(hdcWork))) goto error; + dc_work->attr->stretch_blt_mode = COLORONCOLOR; + if (!NtGdiStretchBlt( hdcWork, 0, 0, widthDest, heightDest, hdcSrc, xSrc, ySrc, widthSrc, heightSrc, SRCCOPY, 0 )) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8988
Jinoh Kang (@iamahuman) commented about dlls/win32u/bitblt.c:
} else bmpWork = NtGdiCreateCompatibleBitmap( hdcDest, widthDest, heightDest ); oldWork = NtGdiSelectBitmap(hdcWork, bmpWork); + + if (!(dc_work = get_dc_ptr(hdcWork))) goto error; + dc_work->attr->stretch_blt_mode = COLORONCOLOR;
This causes memory leak because get\_dc\_ptr increments reference count but you don't decrement it back. Call release\_dc\_ptr when you're done: ```suggestion:-1+0 if (!(dc_work = get_dc_ptr(hdcWork))) goto error; dc_work->attr->stretch_blt_mode = COLORONCOLOR; release_dc_ptr( dc_work ); ``` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8988#note_116101
participants (3)
-
Jinoh Kang (@iamahuman) -
Kun Yang (@yangkun) -
yangkun