]> git.saurik.com Git - wxWidgets.git/commitdiff
adjust Blit destination rect if source rect is clipped
authorPaul Cornett <paulcor@bullseye.com>
Thu, 8 Mar 2012 17:06:06 +0000 (17:06 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Thu, 8 Mar 2012 17:06:06 +0000 (17:06 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70844 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/dcgraph.cpp

index 9dc59efb53a9537189428a09fb71827672939a88..2e57a41a2cb22789f2560202d9b49cf6e23eaff1 100644 (file)
@@ -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
         {