Mark Harmstone : uxtheme: Resize source image if destination smaller than margins.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Apr 15 08:43:26 CDT 2015
Module: wine
Branch: master
Commit: 2b650fa6db522ae5deb0d09310c0a595a6e3e910
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2b650fa6db522ae5deb0d09310c0a595a6e3e910
Author: Mark Harmstone <hellas at burntcomma.com>
Date: Tue Apr 14 22:12:01 2015 +0100
uxtheme: Resize source image if destination smaller than margins.
---
dlls/uxtheme/draw.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/dlls/uxtheme/draw.c b/dlls/uxtheme/draw.c
index 8a9397d..a7f80fd 100644
--- a/dlls/uxtheme/draw.c
+++ b/dlls/uxtheme/draw.c
@@ -663,9 +663,9 @@ static HRESULT UXTHEME_DrawImageBackground(HTHEME hTheme, HDC hdc, int iPartId,
const DTBGOPTS *pOptions)
{
HRESULT hr = S_OK;
- HBITMAP bmpSrc;
+ HBITMAP bmpSrc, bmpSrcResized = NULL;
HGDIOBJ oldSrc;
- HDC hdcSrc;
+ HDC hdcSrc, hdcOrigSrc = NULL;
RECT rcSrc;
RECT rcDst;
POINT dstSize;
@@ -729,6 +729,34 @@ 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 */
+ 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);
+
+ UXTHEME_StretchBlt(hdcSrc, 0, 0, srcSize.x, srcSize.y, hdcOrigSrc, rcSrc.left, rcSrc.top,
+ rcSrc.right - rcSrc.left, rcSrc.bottom - rcSrc.top, transparent, transparentcolor);
+
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = srcSize.x;
+ rcSrc.bottom = srcSize.y;
+ }
+
hdcDst = hdc;
OffsetViewportOrgEx(hdcDst, rcDst.left, rcDst.top, &org);
@@ -833,6 +861,8 @@ draw_error:
}
SelectObject(hdcSrc, oldSrc);
DeleteDC(hdcSrc);
+ if (bmpSrcResized) DeleteObject(bmpSrcResized);
+ if (hdcOrigSrc) DeleteDC(hdcOrigSrc);
CopyRect(pRect, &rcDst);
return hr;
}
More information about the wine-cvs
mailing list