X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4280b8797f51e28f9c2b960e734f60f31a88325f..f1f5f16f780bb41aa2ea24ccbf728f14c86cc475:/src/common/dcgraph.cpp?ds=inline 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 {