mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 20:19:23 +02:00
Small improvements on coordinate handling on Qt's StretchDraw.
git-svn-id: trunk@10524 -
This commit is contained in:
parent
4b90db323d
commit
315a021fbd
@ -203,6 +203,7 @@ type
|
||||
function RestoreDCData(DCData: PQtDCData): boolean;
|
||||
procedure DebugClipRect(const msg: string);
|
||||
procedure setImage(AImage: TQtImage);
|
||||
procedure CorrectCoordinates(var ARect: TRect);
|
||||
public
|
||||
{ Qt functions }
|
||||
procedure drawPoint(x1: Integer; y1: Integer);
|
||||
@ -842,6 +843,30 @@ begin
|
||||
Widget := QPainter_Create(vImage);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtDeviceContext.CorrectCoordinates
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
|
||||
If you draw an image with negative coordinates
|
||||
(for example x: -50 y: -50 w: 100 h: 100), the result is not well
|
||||
defined in Qt, and could well be: (x: 0 y: 0 w: 100 h: 100)
|
||||
This method corrects the coordinates, cutting the result, so we draw:
|
||||
(x: 0 y: 0 w: 50 h: 50)
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TQtDeviceContext.CorrectCoordinates(var ARect: TRect);
|
||||
var
|
||||
Buffer: Integer;
|
||||
begin
|
||||
if ARect.Left < 0 then ARect.Left := 0;
|
||||
|
||||
if ARect.Top < 0 then ARect.Top := 0;
|
||||
|
||||
{ if ARect.Right > MaxRight then ARect.Right := MaxRight;
|
||||
|
||||
if ARect.Bottom > MaxBottom then ARect.Bottom := MaxBottom;}
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtDeviceContext.CreateDCData
|
||||
Params: None
|
||||
|
@ -2641,12 +2641,6 @@ var
|
||||
SrcRect, DstRect: TRect;
|
||||
Image: QImageH;
|
||||
begin
|
||||
DstRect := Bounds(X, Y, Width, Height);
|
||||
|
||||
SrcRect := Bounds(XSrc, YSrc, SrcWidth, SrcHeight);
|
||||
|
||||
Image := TQtDeviceContext(SrcDC).vImage;
|
||||
|
||||
{$ifdef VerboseQtWinAPI}
|
||||
WriteLn('[WinAPI StretchMaskBlt]',
|
||||
' DestDC:', dbghex(DestDC),
|
||||
@ -2658,6 +2652,16 @@ begin
|
||||
' WSrc:', dbgs(SrcWidth), ' HSrc:', dbgs(SrcHeight));
|
||||
{$endif}
|
||||
|
||||
DstRect := Bounds(X, Y, Width, Height);
|
||||
|
||||
SrcRect := Bounds(XSrc, YSrc, SrcWidth, SrcHeight);
|
||||
|
||||
Image := TQtDeviceContext(SrcDC).vImage;
|
||||
|
||||
TQtDeviceContext(DestDC).CorrectCoordinates(DstRect);
|
||||
|
||||
TQtDeviceContext(DestDC).CorrectCoordinates(SrcRect);
|
||||
|
||||
TQtDeviceContext(DestDC).drawImage(@DstRect, Image, @SrcRect);
|
||||
|
||||
Result := True;
|
||||
|
Loading…
Reference in New Issue
Block a user