From d0f93bc7dcf35f0e136cd8a5fa22ad6bdf1c2501 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Tue, 16 Aug 2011 07:02:37 +0000 Subject: [PATCH] Avoid creating rect with negative size while clipping to DC size. Also, don't convert result of wxDC::GetSize() to device coords, it's already device coords. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68717 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dcgraph.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index a06cd25382..1f7295a12e 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -896,6 +896,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 +924,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() ) -- 2.47.2