uxtheme: Do not resize source image even if destination is smaller than sizing margins.

This partially reverts 2b650fa, which resizes source image if destination is smaller than its sizing
margins. Resizing the source image may result in the destination image missing some edges because
of StretchBlt() calls. Same StretchBlt() calls also produce similar results on Windows. So it seems
that Windows don't resize the source image and only resize the margins to try to keep the edges
crisp.

Fix scroll bar thumb missing edges when it's too small.

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2022-01-25 16:00:23 +08:00 committed by Alexandre Julliard
parent 4311a993dd
commit 7bc708df35
1 changed files with 3 additions and 21 deletions

View File

@ -711,9 +711,9 @@ static HRESULT UXTHEME_DrawImageBackground(HTHEME hTheme, HDC hdc, int iPartId,
const DTBGOPTS *pOptions)
{
HRESULT hr = S_OK;
HBITMAP bmpSrc, bmpSrcResized = NULL;
HBITMAP bmpSrc;
HGDIOBJ oldSrc;
HDC hdcSrc, hdcOrigSrc = NULL;
HDC hdcSrc;
RECT rcSrc;
RECT rcDst;
POINT dstSize;
@ -777,33 +777,17 @@ static HRESULT UXTHEME_DrawImageBackground(HTHEME hTheme, HDC hdc, int iPartId,
GetThemeMargins(hTheme, hdc, iPartId, iStateId, TMT_SIZINGMARGINS, NULL, &sm);
/* Resize source image if destination smaller than margins */
/* Resize sizing margins if destination is smaller */
if (sm.cyTopHeight + sm.cyBottomHeight > dstSize.y || sm.cxLeftWidth + sm.cxRightWidth > dstSize.x) {
if (sm.cyTopHeight + sm.cyBottomHeight > dstSize.y) {
sm.cyTopHeight = MulDiv(sm.cyTopHeight, dstSize.y, srcSize.y);
sm.cyBottomHeight = dstSize.y - sm.cyTopHeight;
srcSize.y = dstSize.y;
}
if (sm.cxLeftWidth + sm.cxRightWidth > dstSize.x) {
sm.cxLeftWidth = MulDiv(sm.cxLeftWidth, dstSize.x, srcSize.x);
sm.cxRightWidth = dstSize.x - sm.cxLeftWidth;
srcSize.x = dstSize.x;
}
hdcOrigSrc = hdcSrc;
hdcSrc = CreateCompatibleDC(NULL);
bmpSrcResized = CreateBitmap(srcSize.x, srcSize.y, 1, 32, NULL);
SelectObject(hdcSrc, bmpSrcResized);
/* Use ALPHABLEND_NONE because the image is getting resized, rather than blended with the target */
UXTHEME_StretchBlt(hdcSrc, 0, 0, srcSize.x, srcSize.y, hdcOrigSrc, rcSrc.left, rcSrc.top,
rcSrc.right - rcSrc.left, rcSrc.bottom - rcSrc.top, ALPHABLEND_NONE, 0);
rcSrc.left = 0;
rcSrc.top = 0;
rcSrc.right = srcSize.x;
rcSrc.bottom = srcSize.y;
}
hdcDst = hdc;
@ -910,8 +894,6 @@ draw_error:
}
SelectObject(hdcSrc, oldSrc);
DeleteDC(hdcSrc);
if (bmpSrcResized) DeleteObject(bmpSrcResized);
if (hdcOrigSrc) DeleteDC(hdcOrigSrc);
*pRect = rcDst;
return hr;
}