[PATCH v4 0/2] 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)    -- v4: Apply 1 suggestion(s) to 1 file(s) 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/win32u/bitblt.c b/dlls/win32u/bitblt.c index a9f6f70daf6..d8c8aace7f0 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,11 @@ 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; + release_dc_ptr( dc_work ); + if (!NtGdiStretchBlt( hdcWork, 0, 0, widthDest, heightDest, hdcSrc, xSrc, ySrc, widthSrc, heightSrc, SRCCOPY, 0 )) { @@ -937,6 +943,7 @@ error: release_dc_ptr( dc_src ); NtGdiGetAndSetDCDword( hdcDest, NtGdiSetBkColor, oldBackground, NULL ); NtGdiGetAndSetDCDword( hdcDest, NtGdiSetTextColor, oldForeground, NULL ); + if(hdcWork) { NtGdiSelectBitmap(hdcWork, oldWork); NtGdiDeleteObjectApp( hdcWork ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8988
From: Kun Yang <yangkun(a)uniontech.com> Co-authored-by: Jinoh Kang <jinoh.kang.kr(a)gmail.com> --- dlls/win32u/bitblt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/dlls/win32u/bitblt.c b/dlls/win32u/bitblt.c index d8c8aace7f0..7721d3b4b73 100644 --- a/dlls/win32u/bitblt.c +++ b/dlls/win32u/bitblt.c @@ -943,7 +943,6 @@ error: release_dc_ptr( dc_src ); NtGdiGetAndSetDCDword( hdcDest, NtGdiSetBkColor, oldBackground, NULL ); NtGdiGetAndSetDCDword( hdcDest, NtGdiSetTextColor, oldForeground, NULL ); - if(hdcWork) { NtGdiSelectBitmap(hdcWork, oldWork); NtGdiDeleteObjectApp( hdcWork ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8988
On Tue Oct 14 11:34:18 2025 +0000, Kun Yang wrote:
changed this line in [version 4 of the diff](/wine/wine/-/merge_requests/8988/diffs?diff_id=216296&start_sha=9f893d8b4f1200eb6ed91d42ddb272a5108fbc1d#f3d97f0145ff57de291f14eb7521d8afbbb7f7ac_946_946) @iamahuman I have addressed the suggestion.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/8988#note_119198
Please squash your fix commit into the original commit. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8988#note_119203
participants (4)
-
Jinoh Kang (@iamahuman) -
Kun Yang -
Kun Yang (@yangkun) -
yangkun