From 3caee5cfaad2d6262ad6114c688877abbef4b74e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 5 Apr 2012 13:55:43 +0000 Subject: [PATCH] Really fix source coordinates handling in wxDC::Blit() in wxMSW. It turns out that the changes r71028 were unnecessary (and actually harmful) in most cases, they're only needed when a DIB is used as a source DC. So move the manual coordinates adjustments to the branch of code using StretchDIBits() and don't do it anywhere else. Also don't list this as an incompatible change as wxMSW actually already worked as the other ports in the majority of cases and list it as a simple bug fix instead. Closes #14188. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71095 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 4 +--- src/msw/dc.cpp | 18 +++++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6e4dd762f1..5a493a4d3e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -207,9 +207,6 @@ Changes in behaviour not resulting in compilation errors, please read this! behaved differently in wxMSW and wxGTK/wxOSX before) if more than one item is selected in a control with wxDV_MULTIPLE style. -- wxDC::Blit() now honours the source DC coordinate system in wxMSW, as in all - the other ports, do not apply scaling to source coordinates manually any more. - Changes in behaviour which may result in compilation errors ----------------------------------------------------------- @@ -522,6 +519,7 @@ MSW: - Update stretchable spaces in wxToolBar after tool removal (Catalin Raceanu). - Add support for horizontal mouse wheel events (Lauri Nurmi). - Implement wxGraphicsContext::SetInterpolationQuality() (Eric Jensen). +- Fix coordinate handling in wxDC::Blit() when source DC is a DIB. OSX: diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 7c8b06997b..c7f3cfa665 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -2246,13 +2246,6 @@ bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, return false; } - // We need to interpret source-related coordinates in source DC - // coordinate system. - xsrc = source->LogicalToDeviceX(xsrc); - ysrc = source->LogicalToDeviceY(ysrc); - srcWidth = source->LogicalToDeviceXRel(srcWidth); - srcHeight = source->LogicalToDeviceYRel(srcHeight); - const HDC hdcSrc = GetHdcOf(*implSrc); // if either the source or destination has alpha channel, we must use @@ -2449,6 +2442,17 @@ bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, { SET_STRETCH_BLT_MODE(GetHdc()); + // Unlike all the other functions used here (i.e. AlphaBlt(), + // MaskBlt(), BitBlt() and StretchBlt()), StretchDIBits() does + // not take into account the source DC logical coordinates + // automatically as it doesn't even work with the source HDC. + // So do this manually to ensure that the coordinates are + // interpreted in the same way here as in all the other cases. + xsrc = source->LogicalToDeviceX(xsrc); + ysrc = source->LogicalToDeviceY(ysrc); + srcWidth = source->LogicalToDeviceXRel(srcWidth); + srcHeight = source->LogicalToDeviceYRel(srcHeight); + // Figure out what co-ordinate system we're supposed to specify // ysrc in. const LONG hDIB = ds.dsBmih.biHeight; -- 2.45.2