From 2ea31e1d9274d2a474f5b8d1303e908930a8590c Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 29 Oct 2007 06:42:13 +0000 Subject: [PATCH] qt: - fix previous error in StrechMaskBlt formula (r12581) {Thanks to Felipe and Mattias} - take transform matrix of Source DC into account while Blitting (issue #0010018) git-svn-id: trunk@12622 - --- lcl/interfaces/qt/qtwinapi.inc | 40 ++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 26612314ae..847f10427f 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -4226,8 +4226,7 @@ function TQtWidgetSet.SetScrollInfo(Handle : HWND; SBStyle : Integer; var ScrollBar: TScrollBar; FScrollInfo: TScrollInfo; - R: TRect; - + function PrepareScrollInfo: Integer; var iReCountMax: Integer; @@ -4577,6 +4576,8 @@ var SrcRect, DstRect: TRect; SrcWidthOrig, SrcHeightOrig: Integer; Image: QImageH; + SrcMatrix: QMatrixH; + dx, dy: integer; begin {$ifdef VerboseQtWinAPI} WriteLn('[WinAPI StretchMaskBlt]', @@ -4589,21 +4590,52 @@ begin ' WSrc:', dbgs(SrcWidth), ' HSrc:', dbgs(SrcHeight)); {$endif} + SrcMatrix := QPainter_Matrix(SrcQDC.Widget); Image := SrcQDC.vImage; SrcWidthOrig := QImage_width(Image); SrcHeightOrig := QImage_height(Image); + QMatrix_map(SrcMatrix, XSrc, YSrc, @XSrc, @YSrc); + // our map can have some transformations + if XSrc < 0 then // we cannot draw from negative coord, so we will draw from zero with shift + begin + dx := -XSrc; + XSrc := 0; + end + else + dx := 0; + + if YSrc < 0 then + begin + dy := -YSrc; + YSrc := 0; + end + else + dy := 0; // if passed source Width/Height is more than original then // qt skip that, so for that case we should transform size here // // stretch_factor := Width / SrcWidth; // Width := stretch_factor * (SrcWidthOrig - XSrc); - if (SrcWidth - XSrc <> Width) then + if (SrcWidthOrig - XSrc < SrcWidth) then Width := Width * (SrcWidthOrig - XSrc) div SrcWidth; - if (SrcHeight - YSrc <> Height) then + if (SrcHeightOrig - YSrc < SrcHeight) then Height := Height * (SrcHeightOrig - YSrc) div SrcHeight; + if dx <> 0 then // apply shifts + begin + inc(X, dx); // shift destination + dec(Width, dx); // substract width + dec(SrcWidth, dx); // and dont forget about SrcWidth or we will get unneeded stretching + end; + if dy <> 0 then + begin + inc(Y, dy); + dec(Height, dy); + dec(SrcWidth, dy); + end; + DstRect := Bounds(X, Y, Width, Height); SrcRect := Bounds(XSrc, YSrc, SrcWidth, SrcHeight); DstQDC.CorrectCoordinates(DstRect);