From ce2fe5bc8aff18efcfbc70e242af14c8d5f6fff6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 19 Mar 2007 01:53:53 +0000 Subject: [PATCH] implement DoStretchBlit() in terms of DoBlit() and SetUserScale() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44917 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dcbase.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 0bdd8d06ef..ecc6e00e4c 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -87,16 +87,31 @@ wxDCBase::DoStretchBlit(wxCoord xdest, wxCoord ydest, wxCoord dstWidth, wxCoord dstHeight, wxDC *source, wxCoord xsrc, wxCoord ysrc, - wxCoord WXUNUSED(srcWidth), wxCoord WXUNUSED(srcHeight), + wxCoord srcWidth, wxCoord srcHeight, int rop, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask) { - // temporary default implementation to avoid breaking platforms that don't - // have DoStretchBlit - return DoBlit(xdest, ydest, dstWidth, dstHeight, source, - xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); + wxCHECK_MSG( srcWidth && srcHeight && dstWidth && dstHeight, false, + _T("invalid blit size") ); + + // emulate the stretching by modifying the DC scale + double xscale = (double)srcWidth/dstWidth, + yscale = (double)srcHeight/dstHeight; + + double xscaleOld, yscaleOld; + GetUserScale(&xscaleOld, &yscaleOld); + SetUserScale(xscaleOld/xscale, yscaleOld/yscale); + + bool rc = DoBlit(wxCoord(xdest*xscale), wxCoord(ydest*yscale), + wxCoord(dstWidth*xscale), wxCoord(dstHeight*yscale), + source, + xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask); + + SetUserScale(xscaleOld, yscaleOld); + + return rc; } // ----------------------------------------------------------------------------