Naum
2010-02-22 12:06:49
The current one colours in the found point in red, this isn't any use when debugging points on doors, red dots and the like. So why not have a DebugTPA'Ex' where the user can choose the colour?
{*******************************************************************************
Function DebugTPAEx(Points: TPointArray; PointColor : Integer; BmpName: String): Boolean;
By: Wizzup?
Description: Shows an image of the Debug screen, plotting the color 'PointColor' over the points
stored in Points TPA. If a name is specified, an image will be saved to that path.
*******************************************************************************}
Function DebugTPAEx(Points: TPointArray; PointColor : Integer; BmpName: String): Boolean;
{$ifdef Simba}
var
Bmp,i : integer;
TempTPA : TPointArray;
Box : TBox;
begin
Box := GetTPABounds(Points);
Bmp := BitmapFromClient(Box.x1,Box.y1,Box.x2,Box.y2);
SetLength(TempTPA,Length(Points));
for i := high(points) downto 0 do
TempTPA[i] := Point(Points[i].x-box.x1,Points[i].y - box.y1);
DrawTPABitmap(Bmp,TempTPA, PointColor);
DisplayDebugImgWindow(box.x2-Box.x1 + 1, box.y2-box.y1 + 1);
DrawBitmapDebugImg(Bmp);
if bmpname <> '' then
SaveBitmap(Bmp, ScriptPath + BmpName + '.bmp');
FreeBitmap(Bmp);
end;
{$else}
Var
Width, Height, ClientBMP, I, H: Integer;
xs, ys, xe, ye: Integer;
Begin
Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;
H := High(Points);
For I := 0 To H Do
Begin
xs := Min(xs, Points[i].X);
ys := Min(ys, Points[i].Y);
xe := Max(xe, Points[i].X);
ye := Max(ye, Points[i].Y);
End;
Width := xe - xs;
Height := ye - ys;
DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');
CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
For I := 0 To H Do
FastSetPixel(ClientBMP, Points[i].X - xs, Points[i].Y - ys, PointColor);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);
FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;
{$endif}
{*******************************************************************************
Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;
By: Wizzup? edited by Naum
Description: Shows an image of the Debug screen, plotting colors over the points
stored in Points TPA. If a name is specified, an image will be saved to that path.
*******************************************************************************}
Function DebugTPA(Points: TPointArray; BmpName: String) : Boolean;
Begin
Result := DebugTPAEx(Points, ClRed, BmpName);
End;