]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dcgraph.cpp
Read TIFF images from top to bottom instead of bottom to top.
[wxWidgets.git] / src / common / dcgraph.cpp
index a06cd25382a4ec19db041675f1a142b9e1fb23bf..812ca0e4edc4628208da3cec2c4caa196c89a453 100644 (file)
@@ -121,6 +121,12 @@ wxGCDC::wxGCDC(const wxEnhMetaFileDC& dc)
 }
 #endif
 
+wxGCDC::wxGCDC(wxGraphicsContext* context) :
+    wxDC( new wxGCDCImpl( this ) )
+{
+    SetGraphicsContext(context);
+}
+
 wxGCDC::wxGCDC() :
   wxDC( new wxGCDCImpl( this ) )
 {
@@ -896,6 +902,17 @@ bool wxGCDCImpl::DoStretchBlit(
         return false;
     }
 
+    wxRect subrect(source->LogicalToDeviceX(xsrc),
+                   source->LogicalToDeviceY(ysrc),
+                   source->LogicalToDeviceXRel(srcWidth),
+                   source->LogicalToDeviceYRel(srcHeight));
+    // clip the subrect down to the size of the source DC
+    wxRect clip;
+    source->GetSize(&clip.width, &clip.height);
+    subrect.Intersect(clip);
+    if (subrect.width == 0)
+        return true;
+
     bool retval = true;
 
     wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
@@ -913,21 +930,6 @@ bool wxGCDCImpl::DoStretchBlit(
             ysrcMask = ysrc;
         }
 
-        wxRect subrect(source->LogicalToDeviceX(xsrc),
-                       source->LogicalToDeviceY(ysrc),
-                       source->LogicalToDeviceXRel(srcWidth),
-                       source->LogicalToDeviceYRel(srcHeight));
-
-        // if needed clip the subrect down to the size of the source DC
-        wxCoord sw, sh;
-        source->GetSize(&sw, &sh);
-        sw = source->LogicalToDeviceXRel(sw);
-        sh = source->LogicalToDeviceYRel(sh);
-        if (subrect.x + subrect.width > sw)
-            subrect.width = sw - subrect.x;
-        if (subrect.y + subrect.height > sh)
-            subrect.height = sh - subrect.y;
-
         wxBitmap blit = source->GetAsBitmap( &subrect );
 
         if ( blit.IsOk() )