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-12-31 13:17:49 -05:00
|
|
|
bitmaps,{x ,}mufasatypes,dtm,dtmutil, ocrutil ,graphics ,colour_conv,math,
|
|
|
|
updater
|
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 }
|
|
|
|
|
2009-12-04 15:57:00 -05:00
|
|
|
const
|
|
|
|
CW = 800;
|
|
|
|
CH = 600;
|
|
|
|
|
|
|
|
function randomdtm(a: integer): pdtm;
|
|
|
|
var
|
|
|
|
i: integer;
|
|
|
|
begin
|
|
|
|
initdtm(result, a);
|
|
|
|
for i := 1 to result.l - 1 do
|
|
|
|
begin
|
|
|
|
result.p[i] := point(random(30) - 15, random(30) - 15);
|
|
|
|
result.c[i] := 0;
|
|
|
|
result.t[i] := random(255);
|
|
|
|
result.asz [i] := random(5);
|
|
|
|
result.ash[i] := 0;
|
|
|
|
writeln(format('dtm: (%d, %d) c: %d, t: %d, asz: %d', [result.p[i].x,
|
|
|
|
result.p[i].y, result.c[i], result.t[i], result.asz[i]]));
|
|
|
|
end;
|
|
|
|
result.c[0] := 255;
|
|
|
|
end;
|
|
|
|
|
2009-12-31 15:38:40 -05:00
|
|
|
var
|
|
|
|
aTime: dword;
|
|
|
|
|
|
|
|
function myChange: boolean;
|
|
|
|
begin
|
|
|
|
if gettickcount-atime > 1000 then
|
|
|
|
result := true
|
|
|
|
else
|
|
|
|
result := false;
|
|
|
|
end;
|
|
|
|
|
2009-10-23 18:21:14 -04:00
|
|
|
procedure MufasaTests.DoRun;
|
|
|
|
|
2009-12-17 18:13:02 -05:00
|
|
|
|
2009-12-31 13:17:49 -05:00
|
|
|
{const
|
2009-12-17 18:13:02 -05:00
|
|
|
ocr_Limit_High = 191;
|
2009-12-17 09:54:21 -05:00
|
|
|
ocr_Limit_Low = 65;
|
|
|
|
|
2009-12-17 18:13:02 -05:00
|
|
|
ocr_White = 16777215;
|
|
|
|
ocr_Green = 65280;
|
|
|
|
ocr_Red = 255;
|
|
|
|
ocr_Yellow = 65535;
|
|
|
|
ocr_Blue = 16776960;
|
|
|
|
ocr_ItemC = 16744447;
|
|
|
|
|
2009-12-31 13:17:49 -05:00
|
|
|
ocr_Purple = 8388736; }
|
2009-12-17 18:13:02 -05:00
|
|
|
|
2009-10-23 18:21:14 -04:00
|
|
|
var
|
|
|
|
ErrorMsg: String;
|
2009-12-31 13:17:49 -05:00
|
|
|
{ Time: DWord;
|
2009-10-23 18:21:14 -04:00
|
|
|
C: TClient;
|
2009-12-17 09:54:21 -05:00
|
|
|
I, w, h,x,y: Integer;
|
2009-12-01 18:41:43 -05:00
|
|
|
dtm: pdtm;
|
|
|
|
p:tpointarray;
|
2009-12-17 09:54:21 -05:00
|
|
|
bmp, bmprs: TMufasaBitmap;
|
2009-12-31 13:17:49 -05:00
|
|
|
tbmp: TBitmap;
|
2009-12-17 09:54:21 -05:00
|
|
|
r,g,b:integer;
|
2009-12-31 13:17:49 -05:00
|
|
|
t:Dword; }
|
|
|
|
up: TMMLFileDownloader;
|
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;
|
|
|
|
|
2009-12-31 15:38:40 -05:00
|
|
|
atime:=gettickcount;
|
|
|
|
|
2009-12-31 13:17:49 -05:00
|
|
|
up := TMMLFileDownloader.Create;
|
|
|
|
up.FileURL:='http://www.villavu.com/pics/desktop.png';
|
|
|
|
up.ReplacementFile:='test.png';
|
2009-12-31 15:38:40 -05:00
|
|
|
up.OnBeat:=@myChange;
|
|
|
|
try
|
|
|
|
up.DownloadAndSave;
|
|
|
|
up.Replace;
|
|
|
|
finally
|
|
|
|
writeln(inttostr(gettickcount-atime));
|
|
|
|
up.Free;
|
|
|
|
end;
|
|
|
|
|
2009-12-31 13:17:49 -05:00
|
|
|
|
|
|
|
|
2009-12-17 18:13:02 -05:00
|
|
|
|
|
|
|
{ clOlive = false point }
|
|
|
|
{ clSilver = false shadow }
|
|
|
|
{ clLime = false shadow}
|
|
|
|
|
2009-10-23 18:21:14 -04:00
|
|
|
{ add your program here }
|
2009-12-17 09:54:21 -05:00
|
|
|
|
2009-12-31 13:17:49 -05:00
|
|
|
{ tbmp:=TBitmap.Create;
|
|
|
|
tbmp.LoadFromFile('/home/merlijn/Programs/mufasa/pics/16.bmp');
|
2009-12-17 09:54:21 -05:00
|
|
|
|
|
|
|
bmprs := TMufasaBitmap.Create;
|
2009-12-31 13:17:49 -05:00
|
|
|
bmprs.SetSize(10,10);
|
|
|
|
|
|
|
|
bmprs.LoadFromRawImage(tbmp.RawImage);
|
|
|
|
tbmp.Free;
|
|
|
|
tbmp := bmprs.ToTBitmap;
|
|
|
|
}
|
|
|
|
{ for y := 0 to tbmp.Height -1 do
|
|
|
|
for x := 0 to tbmp.width -1 do
|
2009-12-17 09:54:21 -05:00
|
|
|
begin
|
2009-12-31 13:17:49 -05:00
|
|
|
writeln(format('(%d, %d) = %d , %d', [x,y,tbmp.Canvas.pixels[x,y],bmprs.FastGetPixel(x,y)]));
|
|
|
|
colortorgb(tbmp.Canvas.pixels[x,y],r,g,b);
|
|
|
|
writeln(format('%d,%d,%d', [r,g,b]));
|
|
|
|
colortorgb(bmprs.FastGetPixel(x,y),r,g,b);
|
|
|
|
writeln(format('%d,%d,%d', [r,g,b]));
|
|
|
|
end; }
|
|
|
|
//bmprs.LoadFromFile('/home/merlijn/Programs/mufasa/pics/16.bmp');
|
|
|
|
{C := TClient.Create;
|
|
|
|
C.MWindow.SetTarget(bmprs); }
|
|
|
|
|
|
|
|
|
|
|
|
{ bmp.SaveToFile('/tmp/output.bmp');
|
|
|
|
tbmp.SaveToFile('/tmp/output2.bmp');
|
2009-12-17 09:54:21 -05:00
|
|
|
//bmp.OnDestroy:=nil;
|
2009-11-03 07:57:39 -05:00
|
|
|
bmp.Free;
|
2009-12-31 13:17:49 -05:00
|
|
|
tbmp.Free; }
|
|
|
|
// C.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.
|
|
|
|
|
2009-12-01 18:41:43 -05:00
|
|
|
|
|
|
|
{ {$WARNING Change This Path!}
|
|
|
|
C.MOCR.InitTOCR('/home/merlijn/Programs/mufasa/Fonts/');
|
|
|
|
//C.MOCR.InitTOCR('/home/merlijn/Programs/mufasa/ben/');
|
|
|
|
|
|
|
|
{C.MWindow.GetDimensions(W, H);
|
|
|
|
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!');
|
|
|
|
end; }
|
|
|
|
|
|
|
|
|
|
|
|
bmp := TMufasaBitmap.Create;
|
|
|
|
|
|
|
|
{$WARNING Change This Path!}
|
|
|
|
{ bmp.LoadFromFile('/home/merlijn/Programs/mufasa/UpText/text1.bmp');
|
|
|
|
//bmp.LoadFromFile('/home/merlijn/Programs/mufasa/output.bmp');
|
|
|
|
|
|
|
|
writeln(inttostr(bmp.Width) + ', ' + inttostr(bmp.height));
|
|
|
|
{C.MWindow.SetTarget(x.TWindow(94371927)); }
|
|
|
|
C.MWindow.SetTarget(bmp);
|
|
|
|
|
|
|
|
Time := GetTickCount;
|
|
|
|
for i := 0 to 100 do
|
|
|
|
C.MOCR.GetUpTextAt(0,0);
|
|
|
|
writeln('Time: ' + FloatToStr(((GetTickCount - Time) / (i + 1))));
|
|
|
|
writeln(C.MOCR.GetUpTextAt(0,0)); }
|
|
|
|
|
|
|
|
//C.MInput.ClickMouse(5,5, mouse_Left);
|
|
|
|
sleep(2000);
|
|
|
|
C.MInput.SendText('a'); }
|