mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-30 12:52:16 -05:00
MML/Core: FindBitmapToleranceIn seems to work.
This commit is contained in:
parent
3b939443e8
commit
6f32e21291
@ -441,6 +441,7 @@ begin
|
|||||||
Result := AllocMem(SizeOf(TCTS1Info));
|
Result := AllocMem(SizeOf(TCTS1Info));
|
||||||
ColorToRGB(Color, PCTS1Info(Result)^.R, PCTS1Info(Result)^.G,
|
ColorToRGB(Color, PCTS1Info(Result)^.R, PCTS1Info(Result)^.G,
|
||||||
PCTS1Info(Result)^.B);
|
PCTS1Info(Result)^.B);
|
||||||
|
|
||||||
PCTS1Info(Result)^.Tol := Tol * Tol;
|
PCTS1Info(Result)^.Tol := Tol * Tol;
|
||||||
end;
|
end;
|
||||||
2:
|
2:
|
||||||
@ -466,6 +467,7 @@ begin
|
|||||||
Color := RGBToColor(R, G, B);
|
Color := RGBToColor(R, G, B);
|
||||||
Result := Create_CTSInfo(cts, Color, Tol, hueMod, satMod);
|
Result := Create_CTSInfo(cts, Color, Tol, hueMod, satMod);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Free_CTSInfo(i: Pointer);
|
procedure Free_CTSInfo(i: Pointer);
|
||||||
begin
|
begin
|
||||||
if assigned(i) then
|
if assigned(i) then
|
||||||
@ -475,22 +477,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function Create_CTSInfo2DArray(cts, w, h: integer; bmp: TMufasaBitmap;
|
function Create_CTSInfo2DArray(cts, w, h: integer; data: TPRGB32Array;
|
||||||
Tolerance: Integer; hueMod, satMod: Extended): TCTSInfo2DArray;
|
Tolerance: Integer; hueMod, satMod: Extended): TCTSInfo2DArray;
|
||||||
var
|
var
|
||||||
x, y: integer;
|
x, y: integer;
|
||||||
data: PRGB32;
|
|
||||||
begin
|
begin
|
||||||
setlength(result,h+1,w+1);
|
SetLength(Result,h+1,w+1);
|
||||||
|
|
||||||
w := bmp.width;
|
|
||||||
data := bmp.fdata;
|
|
||||||
|
|
||||||
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
|
begin
|
||||||
result[y][x] := Create_CTSInfo(cts,
|
Result[y][x] := Create_CTSInfo(cts,
|
||||||
data[y*w+x].R, data[y*w+x].G, data[y*w+x].B,
|
data[y][x].R, data[y][x].G, data[y][x].B,
|
||||||
Tolerance, hueMod, satMod);
|
Tolerance, hueMod, satMod);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1639,9 +1637,6 @@ begin
|
|||||||
TClient(Client).IOManager.FreeReturnData;
|
TClient(Client).IOManager.FreeReturnData;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
|
||||||
TODO: Implement HSLRows?
|
|
||||||
}
|
|
||||||
function TMFinder.FindBitmapToleranceIn(bitmap: TMufasaBitmap; out x, y: Integer; xs,
|
function TMFinder.FindBitmapToleranceIn(bitmap: TMufasaBitmap; out x, y: Integer; xs,
|
||||||
ys, xe, ye: Integer; tolerance: Integer): Boolean;
|
ys, xe, ye: Integer; tolerance: Integer): Boolean;
|
||||||
var
|
var
|
||||||
@ -1653,6 +1648,7 @@ var
|
|||||||
tmpY : integer;
|
tmpY : integer;
|
||||||
dX, dY, xx, yy: Integer;
|
dX, dY, xx, yy: Integer;
|
||||||
SkipCoords : T2DBoolArray;
|
SkipCoords : T2DBoolArray;
|
||||||
|
a: TRGB32;
|
||||||
|
|
||||||
ctsinfoarray: TCTSInfo2DArray;
|
ctsinfoarray: TCTSInfo2DArray;
|
||||||
compare: TCTSCompareFunction;
|
compare: TCTSCompareFunction;
|
||||||
@ -1680,29 +1676,10 @@ begin
|
|||||||
dX := dX - bmpW;
|
dX := dX - bmpW;
|
||||||
dY := dY - bmpH;
|
dY := dY - bmpH;
|
||||||
|
|
||||||
ctsinfoarray := Create_CTSInfo2DArray(Self.CTS, bmpW, bmpH, bitmap,
|
ctsinfoarray := Create_CTSInfo2DArray(Self.CTS, bmpW, bmpH, BmpRowData,
|
||||||
Tolerance, self.hueMod, self.satMod);
|
Tolerance, self.hueMod, self.satMod);
|
||||||
compare := Get_CTSCompare(Self.CTS);
|
compare := Get_CTSCompare(Self.CTS);
|
||||||
|
|
||||||
// for yBmp := 0 to BmpH do
|
|
||||||
// begin
|
|
||||||
// tmpY := yBmp + yy;
|
|
||||||
// for xBmp := 0 to BmpW do
|
|
||||||
// begin
|
|
||||||
// writeln('BmpRowData: ' + IntToStr(BmpRowData[yBmp][xBmp].R) + ', ' +
|
|
||||||
// IntToStr(BmpRowData[yBmp][xBmp].G)
|
|
||||||
// + ', ' + IntToStr(BmpRowData[yBmp][xBmp].B));
|
|
||||||
//
|
|
||||||
// case self.cts of
|
|
||||||
// 0, 1: writeln('ctsinfo: ' +
|
|
||||||
// IntToStr(TCTS1Info(ctsinfoarray[yBmp][xBmp]).R) + ', ' +
|
|
||||||
// IntToStr(TCTS1Info(ctsinfoarray[yBmp][xBmp]).G) + ', ' +
|
|
||||||
// IntToStr(TCTS1Info(ctsinfoarray[yBmp][xBmp]).B));
|
|
||||||
// end;
|
|
||||||
//
|
|
||||||
// end;
|
|
||||||
// end;
|
|
||||||
|
|
||||||
//Get the "skip coords".
|
//Get the "skip coords".
|
||||||
CalculateBitmapSkipCoords(Bitmap,SkipCoords);
|
CalculateBitmapSkipCoords(Bitmap,SkipCoords);
|
||||||
for yy := 0 to dY do
|
for yy := 0 to dY do
|
||||||
@ -1720,7 +1697,6 @@ begin
|
|||||||
MainRowdata[tmpY][xBmp + xx].R,MainRowdata[tmpY][xBmp + xx].G,MainRowdata[tmpY][xBmp + xx].B,
|
MainRowdata[tmpY][xBmp + xx].R,MainRowdata[tmpY][xBmp + xx].G,MainRowdata[tmpY][xBmp + xx].B,
|
||||||
H,S,L,HMod,SMod) then }
|
H,S,L,HMod,SMod) then }
|
||||||
goto NotFoundBmp;
|
goto NotFoundBmp;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//We did find the Bmp, otherwise we would be at the part below
|
//We did find the Bmp, otherwise we would be at the part below
|
||||||
|
Loading…
Reference in New Issue
Block a user