mirror of
https://github.com/moparisthebest/Simba
synced 2025-01-07 03:38:06 -05:00
MML/Finder: FindDTMs rework done.
This commit is contained in:
parent
0b592eef86
commit
a621a6e8da
@ -476,7 +476,24 @@ begin
|
|||||||
raise Exception.Create('Free_CTSInfo: Invalid TCTSInfo passed');
|
raise Exception.Create('Free_CTSInfo: Invalid TCTSInfo passed');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TODO: Not universal, mainly for DTM }
|
||||||
|
function Create_CTSInfoArray(cts: integer; color, tolerance: array of integer;
|
||||||
|
hueMod, satMod: extended): TCTSInfoArray;
|
||||||
|
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
if length(color) <> length(tolerance) then
|
||||||
|
raise Exception.Create('Create_CTSInfoArray: Length(Color) <>'
|
||||||
|
+' Length(Tolerance');
|
||||||
|
SetLength(Result, Length(color));
|
||||||
|
|
||||||
|
for i := High(result) downto 0 do
|
||||||
|
result := Create_CTSInfo(cts, color[i], tolerance[i], hueMod, satMod);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TODO: Not universal, mainly for Bitmap }
|
||||||
function Create_CTSInfo2DArray(cts, w, h: integer; data: TPRGB32Array;
|
function Create_CTSInfo2DArray(cts, w, h: integer; data: TPRGB32Array;
|
||||||
Tolerance: Integer; hueMod, satMod: Extended): TCTSInfo2DArray;
|
Tolerance: Integer; hueMod, satMod: Extended): TCTSInfo2DArray;
|
||||||
var
|
var
|
||||||
@ -486,11 +503,9 @@ begin
|
|||||||
|
|
||||||
for y := 0 to h do
|
for y := 0 to h do
|
||||||
for x := 0 to w do
|
for x := 0 to w do
|
||||||
begin
|
|
||||||
Result[y][x] := Create_CTSInfo(cts,
|
Result[y][x] := Create_CTSInfo(cts,
|
||||||
data[y][x].R, data[y][x].G, data[y][x].B,
|
data[y][x].R, data[y][x].G, data[y][x].B,
|
||||||
Tolerance, hueMod, satMod);
|
Tolerance, hueMod, satMod);
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Free_CTSInfoArray(i: TCTSInfoArray);
|
procedure Free_CTSInfoArray(i: TCTSInfoArray);
|
||||||
@ -498,7 +513,7 @@ var
|
|||||||
c: integer;
|
c: integer;
|
||||||
begin
|
begin
|
||||||
for c := high(i) downto 0 do
|
for c := high(i) downto 0 do
|
||||||
Free_CTSInfo(i[c]);
|
Free_CTSInfo(i[c]);
|
||||||
SetLength(i, 0);
|
SetLength(i, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2040,16 +2055,9 @@ end;
|
|||||||
//MaxToFind, if it's < 1 it won't stop looking
|
//MaxToFind, if it's < 1 it won't stop looking
|
||||||
function TMFinder.FindDTMs(DTM: TMDTM; out Points: TPointArray; x1, y1, x2, y2, maxToFind: Integer): Boolean;
|
function TMFinder.FindDTMs(DTM: TMDTM; out Points: TPointArray; x1, y1, x2, y2, maxToFind: Integer): Boolean;
|
||||||
var
|
var
|
||||||
//Cache DTM stuff
|
//Cache DTM stuff
|
||||||
Len : integer; //Len of the points
|
Len : integer; //Len of the points
|
||||||
DPoints : PMDTMPoint; //DTM Points
|
DPoints : PMDTMPoint; //DTM Points
|
||||||
// Colours of DTMs
|
|
||||||
clR,clG,clB : array of byte;
|
|
||||||
|
|
||||||
//Similar colors stuff
|
|
||||||
hh,ss,ll: array of extended;
|
|
||||||
hmod,smod: extended;
|
|
||||||
Ccts : integer;
|
|
||||||
|
|
||||||
// Bitwise
|
// Bitwise
|
||||||
b: Array of Array of Integer;
|
b: Array of Array of Integer;
|
||||||
@ -2077,11 +2085,13 @@ var
|
|||||||
|
|
||||||
goodPoints: Array of Boolean;
|
goodPoints: Array of Boolean;
|
||||||
|
|
||||||
|
col_arr, tol_arr: Array of Integer;
|
||||||
|
ctsinfoarray: TCTSInfoArray;
|
||||||
|
compare: TCTSCompareFunction;
|
||||||
|
|
||||||
label theEnd;
|
label theEnd;
|
||||||
label AnotherLoopEnd;
|
label AnotherLoopEnd;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// Is the area valid?
|
// Is the area valid?
|
||||||
DefaultOperations(x1, y1, x2, y2);
|
DefaultOperations(x1, y1, x2, y2);
|
||||||
@ -2113,21 +2123,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// C = DTM.C
|
// C = DTM.C
|
||||||
SetLength(clR,Len);
|
|
||||||
SetLength(clG,Len);
|
|
||||||
SetLength(clB,Len);
|
|
||||||
for i := 0 to Len - 1 do
|
for i := 0 to Len - 1 do
|
||||||
ColorToRGB(DPoints[i].c,clR[i],clG[i],clB[i]);
|
begin
|
||||||
|
col_arr[i] := DPoints[i].c;
|
||||||
|
tol_arr[i] := DPoints[i].t;
|
||||||
|
end;
|
||||||
|
|
||||||
SetLength(hh,Len);
|
ctsinfoarray := Create_CTSInfoArray(Self.CTS,
|
||||||
SetLength(ss,Len);
|
col_arr, tol_arr, self.hueMod, self.satMod);
|
||||||
SetLength(ll,Len);
|
compare := Get_CTSCompare(Self.CTS);
|
||||||
for i := 0 to Len - 1 do
|
|
||||||
ColorToHSL(DPoints[i].c,hh[i],ss[i],ll[i]);
|
|
||||||
|
|
||||||
GetToleranceSpeed2Modifiers(hMod, sMod);
|
|
||||||
|
|
||||||
ccts := CTS;
|
|
||||||
|
|
||||||
// Retreive Client Data.
|
// Retreive Client Data.
|
||||||
PtrData := TClient(Client).IOManager.ReturnData(x1, y1, W + 1, H + 1);
|
PtrData := TClient(Client).IOManager.ReturnData(x1, y1, W + 1, H + 1);
|
||||||
@ -2165,7 +2169,7 @@ 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);
|
||||||
// if SimilarColors(dtm.c[i], rgbtocolor(cd[yyy][xxx].R, cd[yyy][xxx].G, cd[yyy][xxx].B), DPoints[i].t) then
|
// if SimilarColors(dtm.c[i], rgbtocolor(cd[yyy][xxx].R, cd[yyy][xxx].G, cd[yyy][xxx].B), DPoints[i].t) then
|
||||||
if ColorSame(ccts,DPoints[i].t,clR[i],clG[i],clB[i],cd[yyy][xxx].R, cd[yyy][xxx].G, cd[yyy][xxx].B,hh[i],ss[i],ll[i],hmod,smod) then
|
if compare(ctsinfoarray[i], @cd[yyy][xxx]) then
|
||||||
b[xxx][yyy] := b[xxx][yyy] or (1 shl i);
|
b[xxx][yyy] := b[xxx][yyy] or (1 shl i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2194,6 +2198,8 @@ begin
|
|||||||
AnotherLoopEnd:
|
AnotherLoopEnd:
|
||||||
end;
|
end;
|
||||||
TheEnd:
|
TheEnd:
|
||||||
|
|
||||||
|
Free_CTSInfoArray(ctsinfoarray);
|
||||||
TClient(Client).IOManager.FreeReturnData;
|
TClient(Client).IOManager.FreeReturnData;
|
||||||
|
|
||||||
SetLength(Points, pc);
|
SetLength(Points, pc);
|
||||||
|
Loading…
Reference in New Issue
Block a user