From: Paul Cornett Date: Thu, 8 Mar 2012 17:06:06 +0000 (+0000) Subject: adjust Blit destination rect if source rect is clipped X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/be88fea9ea2d2d15bec03956efeb388d3f6b0938 adjust Blit destination rect if source rect is clipped git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70844 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 9dc59efb53..2e57a41a2c 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -903,6 +903,7 @@ bool wxGCDCImpl::DoStretchBlit( source->LogicalToDeviceY(ysrc), source->LogicalToDeviceXRel(srcWidth), source->LogicalToDeviceYRel(srcHeight)); + const wxRect subrectOrig = subrect; // clip the subrect down to the size of the source DC wxRect clip; source->GetSize(&clip.width, &clip.height); @@ -934,8 +935,19 @@ bool wxGCDCImpl::DoStretchBlit( if ( !useMask && blit.GetMask() ) blit.SetMask(NULL); - m_graphicContext->DrawBitmap( blit, xdest, ydest, - dstWidth, dstHeight); + double x = xdest; + double y = ydest; + double w = dstWidth; + double h = dstHeight; + // adjust dest rect if source rect is clipped + if (subrect.width != subrectOrig.width || subrect.height != subrectOrig.height) + { + x += (subrect.x - subrectOrig.x) / double(subrectOrig.width) * dstWidth; + y += (subrect.y - subrectOrig.y) / double(subrectOrig.height) * dstHeight; + w *= double(subrect.width) / subrectOrig.width; + h *= double(subrect.height) / subrectOrig.height; + } + m_graphicContext->DrawBitmap(blit, x, y, w, h); } else {