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
This commit is contained in:
@@ -896,6 +896,17 @@ bool wxGCDCImpl::DoStretchBlit(
|
|||||||
return false;
|
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;
|
bool retval = true;
|
||||||
|
|
||||||
wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
|
wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
|
||||||
@@ -913,21 +924,6 @@ bool wxGCDCImpl::DoStretchBlit(
|
|||||||
ysrcMask = ysrc;
|
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 );
|
wxBitmap blit = source->GetAsBitmap( &subrect );
|
||||||
|
|
||||||
if ( blit.IsOk() )
|
if ( blit.IsOk() )
|
||||||
|
Reference in New Issue
Block a user