LCL: combined duplicate code IntersectRect

git-svn-id: trunk@27848 -
This commit is contained in:
mattias 2010-10-25 08:32:44 +00:00
parent 2c5c4c2609
commit 584dd6f786
2 changed files with 6 additions and 19 deletions

View File

@ -276,6 +276,8 @@ function CopyImageData(AWidth, AHeight, ARowStride: Integer; ABPP: Word;
ADestinationOrder: TRawImageLineOrder; ADestinationEnd: TRawImageLineEnd;
out ADestination: Pointer; out ASize: PtrUInt): Boolean;
function GetRectIntersect(var DestRect: TRect; const SrcRect1, SrcRect2: TRect): Boolean;
var
MissingBits: array[0..15] of array[0..7] of word;
@ -563,7 +565,7 @@ begin
end;
{------------------------------------------------------------------------------
Function: IntersectRect
Function: GetRectIntersect
Params: var DestRect: TRect; const SrcRect1, SrcRect2: TRect
Returns: Boolean
@ -572,7 +574,7 @@ end;
SrcRect2. If SrcRect1 and SrcRect2 do not overlapp the Result is false, else
true.
------------------------------------------------------------------------------}
function IntersectRect(var DestRect: TRect;
function GetRectIntersect(var DestRect: TRect;
const SrcRect1, SrcRect2: TRect): Boolean;
begin
Result := False;
@ -1419,7 +1421,7 @@ begin
ADst.ReleaseData;
// get intersection
IntersectRect(R, Rect(0, 0, Description.Width, Description.Height), ARect);
GetRectIntersect(R, Rect(0, 0, Description.Width, Description.Height), ARect);
ADst.Description.Width := R.Right - R.Left;
ADst.Description.Height := R.Bottom - R.Top;
if (ADst.Description.Width <= 0)

View File

@ -1313,22 +1313,7 @@ end;
function IntersectRect(var DestRect: TRect;
const SrcRect1, SrcRect2: TRect): Boolean;
begin
Result := False;
// test if rectangles intersects
Result:=(SrcRect2.Left < SrcRect1.Right)
and (SrcRect2.Right > SrcRect1.Left)
and (SrcRect2.Top < SrcRect1.Bottom)
and (SrcRect2.Bottom > SrcRect1.Top);
if Result then begin
DestRect.Left:=Max(SrcRect1.Left,SrcRect2.Left);
DestRect.Top:=Max(SrcRect1.Top,SrcRect2.Top);
DestRect.Right:=Min(SrcRect1.Right,SrcRect2.Right);
DestRect.Bottom:=Min(SrcRect1.Bottom,SrcRect2.Bottom);
end else begin
SetRectEmpty(DestRect);
end;
Result := GetRectIntersect(DestRect,SrcRect1,SrcRect2);
end;
{------------------------------------------------------------------------------