mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-11 22:20:36 +01:00
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 -
This commit is contained in:
parent
669ef32831
commit
2ea31e1d92
@ -4226,7 +4226,6 @@ function TQtWidgetSet.SetScrollInfo(Handle : HWND; SBStyle : Integer;
|
|||||||
var
|
var
|
||||||
ScrollBar: TScrollBar;
|
ScrollBar: TScrollBar;
|
||||||
FScrollInfo: TScrollInfo;
|
FScrollInfo: TScrollInfo;
|
||||||
R: TRect;
|
|
||||||
|
|
||||||
function PrepareScrollInfo: Integer;
|
function PrepareScrollInfo: Integer;
|
||||||
var
|
var
|
||||||
@ -4577,6 +4576,8 @@ var
|
|||||||
SrcRect, DstRect: TRect;
|
SrcRect, DstRect: TRect;
|
||||||
SrcWidthOrig, SrcHeightOrig: Integer;
|
SrcWidthOrig, SrcHeightOrig: Integer;
|
||||||
Image: QImageH;
|
Image: QImageH;
|
||||||
|
SrcMatrix: QMatrixH;
|
||||||
|
dx, dy: integer;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
WriteLn('[WinAPI StretchMaskBlt]',
|
WriteLn('[WinAPI StretchMaskBlt]',
|
||||||
@ -4589,21 +4590,52 @@ begin
|
|||||||
' WSrc:', dbgs(SrcWidth), ' HSrc:', dbgs(SrcHeight));
|
' WSrc:', dbgs(SrcWidth), ' HSrc:', dbgs(SrcHeight));
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
SrcMatrix := QPainter_Matrix(SrcQDC.Widget);
|
||||||
Image := SrcQDC.vImage;
|
Image := SrcQDC.vImage;
|
||||||
SrcWidthOrig := QImage_width(Image);
|
SrcWidthOrig := QImage_width(Image);
|
||||||
SrcHeightOrig := QImage_height(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
|
// if passed source Width/Height is more than original then
|
||||||
// qt skip that, so for that case we should transform size here
|
// qt skip that, so for that case we should transform size here
|
||||||
//
|
//
|
||||||
// stretch_factor := Width / SrcWidth;
|
// stretch_factor := Width / SrcWidth;
|
||||||
// Width := stretch_factor * (SrcWidthOrig - XSrc);
|
// Width := stretch_factor * (SrcWidthOrig - XSrc);
|
||||||
if (SrcWidth - XSrc <> Width) then
|
if (SrcWidthOrig - XSrc < SrcWidth) then
|
||||||
Width := Width * (SrcWidthOrig - XSrc) div SrcWidth;
|
Width := Width * (SrcWidthOrig - XSrc) div SrcWidth;
|
||||||
|
|
||||||
if (SrcHeight - YSrc <> Height) then
|
if (SrcHeightOrig - YSrc < SrcHeight) then
|
||||||
Height := Height * (SrcHeightOrig - YSrc) div SrcHeight;
|
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);
|
DstRect := Bounds(X, Y, Width, Height);
|
||||||
SrcRect := Bounds(XSrc, YSrc, SrcWidth, SrcHeight);
|
SrcRect := Bounds(XSrc, YSrc, SrcWidth, SrcHeight);
|
||||||
DstQDC.CorrectCoordinates(DstRect);
|
DstQDC.CorrectCoordinates(DstRect);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user