2009-10-23 18:21:14 -04:00
|
|
|
program project1;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
|
|
|
cthreads,
|
|
|
|
{$ENDIF}{$ENDIF}
|
|
|
|
Classes, SysUtils, CustApp,
|
|
|
|
Forms,Interfaces,
|
2009-10-25 16:55:50 -04:00
|
|
|
LCLIntf,
|
2009-11-01 06:07:46 -05:00
|
|
|
Client,
|
2009-11-06 20:57:38 -05:00
|
|
|
bitmaps,x ,mufasatypes
|
2009-10-23 18:21:14 -04:00
|
|
|
|
2009-10-25 16:55:50 -04:00
|
|
|
|
2009-10-23 18:21:14 -04:00
|
|
|
{ you can add units after this };
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ MufasaTests }
|
|
|
|
|
|
|
|
MufasaTests = class(TCustomApplication)
|
|
|
|
protected
|
|
|
|
procedure DoRun; override;
|
|
|
|
public
|
|
|
|
constructor Create(TheOwner: TComponent); override;
|
|
|
|
destructor Destroy; override;
|
|
|
|
procedure WriteHelp; virtual;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ MufasaTests }
|
|
|
|
|
|
|
|
procedure MufasaTests.DoRun;
|
|
|
|
|
|
|
|
var
|
|
|
|
ErrorMsg: String;
|
2009-10-25 16:55:50 -04:00
|
|
|
Time: DWord;
|
2009-10-23 18:21:14 -04:00
|
|
|
C: TClient;
|
2009-11-01 06:07:46 -05:00
|
|
|
I{, W, H, X, Y}: Integer;
|
|
|
|
bmp: TMufasaBitmap;
|
2009-10-25 16:55:50 -04:00
|
|
|
|
2009-10-23 18:21:14 -04:00
|
|
|
begin
|
|
|
|
// quick check parameters
|
|
|
|
ErrorMsg:=CheckOptions('h','help');
|
|
|
|
if ErrorMsg<>'' then begin
|
|
|
|
ShowException(Exception.Create(ErrorMsg));
|
|
|
|
Terminate;
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
// parse parameters
|
|
|
|
if HasOption('h','help') then begin
|
|
|
|
WriteHelp;
|
|
|
|
Terminate;
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ add your program here }
|
|
|
|
C := TClient.Create;
|
2009-11-01 06:07:46 -05:00
|
|
|
{$WARNING Change This Path!}
|
|
|
|
C.MOCR.InitTOCR('/home/merlijn/Programs/mufasa/Fonts/');
|
2009-11-02 19:40:07 -05:00
|
|
|
//C.MOCR.InitTOCR('/home/merlijn/Programs/mufasa/ben/');
|
2009-10-25 16:55:50 -04:00
|
|
|
|
2009-11-01 06:07:46 -05:00
|
|
|
{C.MWindow.GetDimensions(W, H);
|
2009-10-25 16:55:50 -04:00
|
|
|
Time := GetTickCount;
|
|
|
|
for i := 0 to 100 do
|
|
|
|
C.MFinder.FindColor(X, Y, 0, 0, 0, W - 1, H - 1);
|
|
|
|
writeln('Time: ' + IntToStr(GetTickCount - Time));
|
|
|
|
|
|
|
|
if C.MFinder.FindColor(X, Y, 0, 0, 0, W - 1, H - 1) then
|
|
|
|
begin
|
|
|
|
C.MInput.SetMousePos(X, Y);
|
|
|
|
writeln('found!');
|
|
|
|
end else
|
|
|
|
begin
|
|
|
|
writeln('not found!');
|
2009-11-01 06:07:46 -05:00
|
|
|
end; }
|
|
|
|
|
|
|
|
|
|
|
|
bmp := TMufasaBitmap.Create;
|
|
|
|
|
|
|
|
{$WARNING Change This Path!}
|
2009-11-06 20:57:38 -05:00
|
|
|
{ bmp.LoadFromFile('/home/merlijn/Programs/mufasa/UpText/text1.bmp');
|
2009-11-02 19:40:07 -05:00
|
|
|
//bmp.LoadFromFile('/home/merlijn/Programs/mufasa/output.bmp');
|
2009-10-23 18:21:14 -04:00
|
|
|
|
2009-11-01 06:07:46 -05:00
|
|
|
writeln(inttostr(bmp.Width) + ', ' + inttostr(bmp.height));
|
2009-11-03 07:57:39 -05:00
|
|
|
{C.MWindow.SetTarget(x.TWindow(94371927)); }
|
|
|
|
C.MWindow.SetTarget(bmp);
|
2009-10-23 18:21:14 -04:00
|
|
|
|
2009-11-03 07:57:39 -05:00
|
|
|
Time := GetTickCount;
|
2009-11-01 06:07:46 -05:00
|
|
|
for i := 0 to 100 do
|
2009-11-02 19:40:07 -05:00
|
|
|
C.MOCR.GetUpTextAt(0,0);
|
2009-11-03 07:57:39 -05:00
|
|
|
writeln('Time: ' + FloatToStr(((GetTickCount - Time) / (i + 1))));
|
2009-11-06 20:57:38 -05:00
|
|
|
writeln(C.MOCR.GetUpTextAt(0,0)); }
|
|
|
|
|
|
|
|
C.MInput.ClickMouse(5,5, mouse_Left);
|
2009-10-23 18:21:14 -04:00
|
|
|
|
|
|
|
C.Free;
|
2009-11-03 07:57:39 -05:00
|
|
|
bmp.OnDestroy:=nil;
|
|
|
|
bmp.Free;
|
2009-10-23 18:21:14 -04:00
|
|
|
|
|
|
|
|
|
|
|
// stop program loop
|
|
|
|
Terminate;
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor MufasaTests.Create(TheOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create(TheOwner);
|
|
|
|
StopOnException:=True;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor MufasaTests.Destroy;
|
|
|
|
begin
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure MufasaTests.WriteHelp;
|
|
|
|
begin
|
|
|
|
{ add your help code here }
|
|
|
|
writeln('Usage: ',ExeName,' -h');
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
Application: MufasaTests;
|
|
|
|
|
|
|
|
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
|
|
|
|
|
|
|
|
begin
|
|
|
|
Application:=MufasaTests.Create(nil);
|
|
|
|
Application.Title:='My Application';
|
|
|
|
Application.Run;
|
|
|
|
Application.Free;
|
|
|
|
end.
|
|
|
|
|