From cce4a2cec8d491b2120eb02a03bcc1fdf8b8c88e Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 7 Dec 2006 03:07:30 +0000 Subject: [PATCH] clip the bitmap to the size of the source DC in DoBlit if neccessary git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43841 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dcgraph.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index a7d8e0781e..613c6a1bcf 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -732,14 +732,28 @@ bool wxGCDC::DoBlit( ysrcMask = ysrc; } - wxRect subrect(source-> LogicalToDeviceX(xsrc),source-> LogicalToDeviceY(ysrc), - source-> LogicalToDeviceXRel(width),source-> LogicalToDeviceYRel(height)); + wxRect subrect(source->LogicalToDeviceX(xsrc), + source->LogicalToDeviceY(ysrc), + source->LogicalToDeviceXRel(width), + source->LogicalToDeviceYRel(height)); + + // 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.Ok() ) { - m_graphicContext->DrawBitmap( blit, xdest , ydest , width , height ); + m_graphicContext->DrawBitmap( blit, xdest, ydest, + wxMin(width, blit.GetWidth()), + wxMin(height, blit.GetHeight())); } else { -- 2.45.2