mirror of
https://github.com/moparisthebest/Simba
synced 2024-12-23 15:58:51 -05:00
Needs less sleep coding
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@552 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
d2d41920d0
commit
e5854f3eab
@ -65,6 +65,7 @@ var
|
|||||||
dtm: pdtm;
|
dtm: pdtm;
|
||||||
p:tpointarray;
|
p:tpointarray;
|
||||||
bmp: TMufasaBitmap;
|
bmp: TMufasaBitmap;
|
||||||
|
aa: T2DExtendedArray;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// quick check parameters
|
// quick check parameters
|
||||||
@ -84,74 +85,64 @@ begin
|
|||||||
|
|
||||||
{ add your program here }
|
{ add your program here }
|
||||||
C := TClient.Create('.');
|
C := TClient.Create('.');
|
||||||
|
|
||||||
bmp := TMufasaBitmap.Create;
|
bmp := TMufasaBitmap.Create;
|
||||||
//bmp.LoadFromFile('/home/merlijn/Programs/mufasa/pics/smallchars.bmp');
|
|
||||||
bmp.LoadFromFile('/home/merlijn/Programs/mufasa/pics/UpChars.bmp');
|
|
||||||
C.IOManager.SetTarget(bmp);
|
|
||||||
C.MOCR.InitTOCR('/home/merlijn/Programs/mufasa/trunk/Fonts/');
|
|
||||||
// small chars
|
|
||||||
t := GetTickCount;
|
|
||||||
for i := 0 to 100 do
|
|
||||||
C.MOCR.GetTextAt(0,0,0,3,2,65278,2,100,'UpChars');
|
|
||||||
//C.MOCR.GetTextAt(0,0,1,3,2,0,0,100,'SmallChars');
|
|
||||||
writeln(floattostr((gettickcount - t) / 100.0) + ' ms');
|
|
||||||
writeln(C.MOCR.GetTextAt(0,0,0,3,2,65278,2,100,'UpChars'));
|
|
||||||
//writeln(C.MOCR.GetTextAt(0,0,1,3,2,0,0,100,'SmallChars'));
|
|
||||||
|
|
||||||
|
|
||||||
{ bmp := C.MOCR.TextToFontBitmap('Welcome to RuneScape.', 'SmallChars');
|
|
||||||
|
|
||||||
|
|
||||||
bmp.SaveToFile('/tmp/wat.bmp'); }
|
|
||||||
|
|
||||||
{ bmp := TMufasaBitmap.Create;
|
|
||||||
bmp.SetSize(CW,CH);
|
bmp.SetSize(CW,CH);
|
||||||
Writeln(Format('Client W/H: %d, %d', [CW, CH]));
|
Writeln(Format('Client W/H: %d, %d', [CW, CH]));
|
||||||
FillChar(bmp.FData[0],sizeof(trgb32)*CW*CH, 0);
|
FillChar(bmp.FData[0],sizeof(trgb32)*CW*CH, 0);
|
||||||
Randomize;
|
Randomize;
|
||||||
for i := 0 to 500 do
|
{for i := 0 to 2000 do
|
||||||
bmp.fastsetpixel(random(CW), random(CH), 255); }
|
bmp.fastsetpixel(random(CW), random(CH), 255); }
|
||||||
{ bmp.FastSetPixel(8,8,255);
|
|
||||||
bmp.FastSetPixel(9,9,255);
|
bmp.FastSetPixel(50,50,255);
|
||||||
bmp.FastSetPixel(7,7,255);
|
bmp.FastSetPixel(45,45,255);
|
||||||
bmp.FastSetPixel(9,8,255);
|
// bmp.FastSetPixel(7,7,255);
|
||||||
bmp.FastSetPixel(8,9,255); }
|
// bmp.FastSetPixel(9,8,255);
|
||||||
// C.MWindow.SetTarget(bmp);
|
// bmp.FastSetPixel(8,9,255);
|
||||||
|
bmp.savetofile('/tmp/wat.bmp');
|
||||||
|
|
||||||
|
C.IOManager.SetTarget(bmp);
|
||||||
|
|
||||||
|
|
||||||
{ initdtm(dtm, 5);
|
initdtm(dtm, 2);
|
||||||
dtm.p[0] := Point(2, 2);
|
dtm.p[0] := Point(2, 2);
|
||||||
dtm.p[1] := Point(-3, -3);
|
dtm.p[1] := Point(-3, -3);
|
||||||
dtm.p[2] := Point(0, 0);
|
{ dtm.p[2] := Point(0, 0);
|
||||||
dtm.p[3] := Point(1, 1);
|
dtm.p[3] := Point(1, 1);
|
||||||
dtm.p[4] := Point(3, 3);
|
dtm.p[4] := Point(3, 3); }
|
||||||
dtm.c[0] := 255;
|
dtm.c[0] := 255;
|
||||||
dtm.t[0] := 0;
|
dtm.t[0] := 0;
|
||||||
dtm.asz[1] := 1;
|
|
||||||
dtm.ash[1] := dtm_Rectangle; }
|
|
||||||
|
|
||||||
{ dtm := randomdtm(10);
|
dtm.c[1] := 255;
|
||||||
|
dtm.t[1] := 0;
|
||||||
|
dtm.asz[1] := 0;
|
||||||
|
dtm.ash[1] := dtm_Rectangle;
|
||||||
|
|
||||||
|
//dtm := randomdtm(1);
|
||||||
|
|
||||||
// setlength(p, 1);
|
// setlength(p, 1);
|
||||||
C.MFinder.SetToleranceSpeed(1);
|
C.MFinder.SetToleranceSpeed(1);
|
||||||
|
|
||||||
time := GetTickCount;
|
time := GetTickCount;
|
||||||
for i := 0 to 100 do
|
for i := 0 to 0 do
|
||||||
begin
|
begin
|
||||||
setlength(p,0);
|
setlength(p,0);
|
||||||
C.MFinder.FindDTMs(dtm, p, 0, 0,CW-1, CH-1, 0);
|
C.MFinder.FindDTMsRotated(dtm, p, 0, 0,CW-1, CH-1, 0.0, Pi / 4.0, Pi / 10.0, aa, 0);
|
||||||
|
//C.MFinder.FindDTMs(dtm, p, 0, 0,CW-1, CH-1, 0);
|
||||||
end;
|
end;
|
||||||
writeln(inttostr(gettickcount - time) + 'ms');
|
writeln(inttostr(gettickcount - time) + 'ms');
|
||||||
writeln(inttostr(length(p))+ ' points found');
|
writeln(inttostr(length(p))+ ' points found');
|
||||||
|
for i := 0 to high(p) do
|
||||||
|
writeln(format('P[%d]: (%d, %d)', [i,p[i].x,p[i].y]));
|
||||||
setlength(p,0);
|
setlength(p,0);
|
||||||
|
|
||||||
PrintpDTM(tdtmtopDTM(pDTMToTDTM(dtm))); }
|
PrintpDTM(tdtmtopDTM(pDTMToTDTM(dtm)));
|
||||||
|
|
||||||
{for i := 0 to high(p) do
|
for i := 0 to high(p) do
|
||||||
writeln(format('%d: (%d, %d)', [i, p[i].x, p[i].y])); }
|
writeln(format('%d: (%d, %d)', [i, p[i].x, p[i].y]));
|
||||||
|
|
||||||
|
|
||||||
//bmp.OnDestroy:=nil;
|
bmp.OnDestroy:=nil;
|
||||||
//bmp.Free;
|
//bmp.Free;
|
||||||
bmp.Free;
|
bmp.Free;
|
||||||
C.Free;
|
C.Free;
|
||||||
@ -182,6 +173,8 @@ var
|
|||||||
|
|
||||||
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
|
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
|
||||||
|
|
||||||
|
{$R project1.res}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Application:=MufasaTests.Create(nil);
|
Application:=MufasaTests.Create(nil);
|
||||||
Application.Title:='My Application';
|
Application.Title:='My Application';
|
||||||
@ -189,6 +182,25 @@ begin
|
|||||||
Application.Free;
|
Application.Free;
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
{ bmp := TMufasaBitmap.Create;
|
||||||
|
//bmp.LoadFromFile('/home/merlijn/Programs/mufasa/pics/smallchars.bmp');
|
||||||
|
bmp.LoadFromFile('/home/merlijn/Programs/mufasa/pics/UpChars.bmp');
|
||||||
|
C.IOManager.SetTarget(bmp);
|
||||||
|
C.MOCR.InitTOCR('/home/merlijn/Programs/mufasa/trunk/Fonts/');
|
||||||
|
// small chars
|
||||||
|
t := GetTickCount;
|
||||||
|
for i := 0 to 100 do
|
||||||
|
C.MOCR.GetTextAt(0,0,0,3,2,65278,2,100,'UpChars');
|
||||||
|
//C.MOCR.GetTextAt(0,0,1,3,2,0,0,100,'SmallChars');
|
||||||
|
writeln(floattostr((gettickcount - t) / 100.0) + ' ms');
|
||||||
|
writeln(C.MOCR.GetTextAt(0,0,0,3,2,65278,2,100,'UpChars')); }
|
||||||
|
//writeln(C.MOCR.GetTextAt(0,0,1,3,2,0,0,100,'SmallChars'));
|
||||||
|
|
||||||
|
|
||||||
|
{ bmp := C.MOCR.TextToFontBitmap('Welcome to RuneScape.', 'SmallChars');
|
||||||
|
|
||||||
|
|
||||||
|
bmp.SaveToFile('/tmp/wat.bmp'); }
|
||||||
|
|
||||||
{ {$WARNING Change This Path!}
|
{ {$WARNING Change This Path!}
|
||||||
C.MOCR.InitTOCR('/home/merlijn/Programs/mufasa/Fonts/');
|
C.MOCR.InitTOCR('/home/merlijn/Programs/mufasa/Fonts/');
|
||||||
|
@ -28,7 +28,7 @@ unit dtmutil;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, MufasaTypes, tpa;
|
Classes, SysUtils, MufasaTypes;
|
||||||
|
|
||||||
|
|
||||||
Function pDTMToTDTM(Const DTM: pDTM): TDTM;
|
Function pDTMToTDTM(Const DTM: pDTM): TDTM;
|
||||||
@ -54,6 +54,24 @@ const
|
|||||||
implementation
|
implementation
|
||||||
uses math;
|
uses math;
|
||||||
|
|
||||||
|
Function RotatePoints_(Var P: TPointArray; A, cx, cy: Extended): TPointArray ;
|
||||||
|
|
||||||
|
Var
|
||||||
|
I, L: Integer;
|
||||||
|
CosA,SinA : extended;
|
||||||
|
|
||||||
|
Begin
|
||||||
|
L := High(P);
|
||||||
|
CosA := Cos(a);
|
||||||
|
SinA := Sin(a);
|
||||||
|
For I := 0 To L Do
|
||||||
|
Begin
|
||||||
|
P[I].X := Trunc(cx + CosA * (p[i].x - cx) - SinA * (p[i].y - cy));
|
||||||
|
P[I].Y := Trunc(cy + SinA * (p[i].x - cx) + CosA * (p[i].y - cy));
|
||||||
|
End;
|
||||||
|
// I recon it's faster than Point().
|
||||||
|
End;
|
||||||
|
|
||||||
// macro
|
// macro
|
||||||
procedure initdtm(out d: pdtm; len: integer);
|
procedure initdtm(out d: pdtm; len: integer);
|
||||||
var
|
var
|
||||||
@ -204,8 +222,9 @@ procedure NormalizeDTM(var dtm: pdtm);
|
|||||||
var
|
var
|
||||||
i:integer;
|
i:integer;
|
||||||
begin
|
begin
|
||||||
for i := 0 to dtm.l do
|
for i := 1 to dtm.l do
|
||||||
dtm.p[i] := dtm.p[i] - dtm.p[0];
|
dtm.p[i] := dtm.p[i] - dtm.p[0];
|
||||||
|
dtm.p[0] := dtm.p[0] - dtm.p[0];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function ValidMainPointBox(var dtm: pDTM; const x1, y1, x2, y2: Integer): TBox;
|
Function ValidMainPointBox(var dtm: pDTM; const x1, y1, x2, y2: Integer): TBox;
|
||||||
@ -271,10 +290,13 @@ end;
|
|||||||
|
|
||||||
procedure RotateDTM(var dtm: pdtm; angle: extended);
|
procedure RotateDTM(var dtm: pdtm; angle: extended);
|
||||||
|
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
begin
|
begin
|
||||||
if length(dtm.p) = 0 then
|
if length(dtm.p) = 0 then
|
||||||
raise Exception.Create('RotateDTM, no points in DTM.');
|
raise Exception.Create('RotateDTM, no points in DTM.');
|
||||||
RotatePoints(dtm.p, angle, dtm.p[0].x, dtm.p[0].y);
|
|
||||||
|
RotatePoints_(dtm.p, angle, dtm.p[0].x, dtm.p[0].y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function copydtm(const dtm: pdtm): pdtm;
|
function copydtm(const dtm: pdtm): pdtm;
|
||||||
|
@ -1977,7 +1977,7 @@ begin
|
|||||||
for yyy := yy - dtm.asz[i] + dtm.p[i].y to yy + dtm.asz[i]+ dtm.p[i].y do
|
for yyy := yy - dtm.asz[i] + dtm.p[i].y to yy + dtm.asz[i]+ dtm.p[i].y do
|
||||||
begin
|
begin
|
||||||
// If we have not checked this point, check it now.
|
// If we have not checked this point, check it now.
|
||||||
if ch[xxx][yyy+1] and (1 shl i) = 0 then
|
if ch[xxx][yyy] and (1 shl i) = 0 then
|
||||||
begin
|
begin
|
||||||
// Checking point i now. (Store that we matched it)
|
// Checking point i now. (Store that we matched it)
|
||||||
ch[xxx][yyy]:= ch[xxx][yyy] or (1 shl i);
|
ch[xxx][yyy]:= ch[xxx][yyy] or (1 shl i);
|
||||||
@ -2054,20 +2054,15 @@ var
|
|||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
raise Exception.CreateFmt('Not done yet!', []);
|
|
||||||
if not DTMConsistent(_dtm) then
|
if not DTMConsistent(_dtm) then
|
||||||
begin
|
begin
|
||||||
raise Exception.CreateFmt('FindDTMsRotated: DTM is not consistent.', []);
|
raise Exception.CreateFmt('FindDTMsRotated: DTM is not consistent.', []);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Get the area we should search in for the Main Point.
|
NormalizeDTM(_dtm);
|
||||||
//writeln(Format('%d, %d, %d, %d', [x1,y1,x2,y2]));
|
|
||||||
MA := ValidMainPointBox(_DTM, x1, y1, x2, y2);
|
|
||||||
|
|
||||||
//writeln(Format('%d, %d, %d, %d', [MA.x1,MA.y1,MA.x2,MA.y2]));
|
DefaultOperations(x1, y1, x2, y2);
|
||||||
|
|
||||||
DefaultOperations(MA.x1, MA.y1, MA.x2, MA.y2);
|
|
||||||
DTM := copydtm(_DTM);
|
DTM := copydtm(_DTM);
|
||||||
|
|
||||||
setlength(goodPoints, dtm.l);
|
setlength(goodPoints, dtm.l);
|
||||||
@ -2101,6 +2096,8 @@ begin
|
|||||||
while s < eAngle do
|
while s < eAngle do
|
||||||
begin
|
begin
|
||||||
RotateDTM(dtm, s);
|
RotateDTM(dtm, s);
|
||||||
|
MA := ValidMainPointBox(DTM, x1, y1, x2, y2);
|
||||||
|
|
||||||
for yy := MA.y1 -y1 to MA.y2 - y1 do
|
for yy := MA.y1 -y1 to MA.y2 - y1 do
|
||||||
for xx := MA.x1 -x1 to MA.x2 - x1 do
|
for xx := MA.x1 -x1 to MA.x2 - x1 do
|
||||||
begin
|
begin
|
||||||
@ -2117,8 +2114,9 @@ begin
|
|||||||
for xxx := xx - dtm.asz[i] + dtm.p[i].x to xx + dtm.asz[i] + dtm.p[i].x do
|
for xxx := xx - dtm.asz[i] + dtm.p[i].x to xx + dtm.asz[i] + dtm.p[i].x do
|
||||||
for yyy := yy - dtm.asz[i] + dtm.p[i].y to yy + dtm.asz[i]+ dtm.p[i].y do
|
for yyy := yy - dtm.asz[i] + dtm.p[i].y to yy + dtm.asz[i]+ dtm.p[i].y do
|
||||||
begin
|
begin
|
||||||
|
writeln(format('xxx,yyy: %d, %d', [xxx,yyy]));
|
||||||
// If we have not checked this point, check it now.
|
// If we have not checked this point, check it now.
|
||||||
if ch[xxx][yyy+1] and (1 shl i) = 0 then
|
if ch[xxx][yyy] and (1 shl i) = 0 then
|
||||||
begin
|
begin
|
||||||
// Checking point i now. (Store that we matched it)
|
// Checking point i now. (Store that we matched it)
|
||||||
ch[xxx][yyy]:= ch[xxx][yyy] or (1 shl i);
|
ch[xxx][yyy]:= ch[xxx][yyy] or (1 shl i);
|
||||||
@ -2135,6 +2133,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
//writeln(Format('Found point: (%d, %d)', [xx,yy]));
|
//writeln(Format('Found point: (%d, %d)', [xx,yy]));
|
||||||
|
|
||||||
Inc(pc);
|
Inc(pc);
|
||||||
setlength(Points,pc);
|
setlength(Points,pc);
|
||||||
Points[pc-1] := Point(xx + x1, yy + y1);
|
Points[pc-1] := Point(xx + x1, yy + y1);
|
||||||
@ -2149,6 +2148,7 @@ begin
|
|||||||
s := s + aStep;
|
s := s + aStep;
|
||||||
ac := 0;
|
ac := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TheEnd:
|
TheEnd:
|
||||||
TClient(Client).IOManager.FreeReturnData;
|
TClient(Client).IOManager.FreeReturnData;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user