P1nky
2012-01-30 02:24:38
Error: Out Of Range at line 816Line 816:
if ((B.x2-B.x1) > 90) and ((B.y2-B.y1) > 18) then Randomly happens while running my PCer:/
Btw this is located in text.simba
Function GetChooseOptions(TextType: string): Array of TOptions;
var
B,BB, BigBox: TBox;
TPA, TPA1, TPA2: TPointArray;
aTPA, tempatpa: T2DPointArray;
I, L, target, bmp,w,h, cts: Integer;
Colors: TIntegerArray;
begin
target := GetImageTarget;
GetClientDimensions(B.X2, B.Y2);
B := IntToBox(0, 0, B.X2-1, B.Y2-1);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(TPA1, 131843, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(TPA2, 3682593, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := CombineTPA(TPA1, TPA2);
If Length(TPA) < 100 Then
begin
ColorToleranceSpeed(cts);
Exit;
end;
aTPA := SplitTPA(TPA, 10);
For i := 0 to High(ATPA) do
begin
B := GetTPABounds(ATPA[i]);
if ((B.x2-B.x1) > 90) and ((B.y2-B.y1) > 18) then // LINE 816
Break
else
B := IntToBox(0, 0, 0, 0);
end;
If (B.x2 = 0) then
begin
ColorToleranceSpeed(cts);
Exit;
end;
BigBox := B;
//Object Blue, Player White, Item Orange, Action Tan, NPC Yellow, Level Green
Colors := [14342147, 14079443, 3832268, 9677229, 840143, 710915];
SetLength(aTPA, Length(Colors));
for i := 0 to High(Colors) do
FindColorsTolerance(aTPA[i], Colors[i], B.X1, B.Y1, B.X2, B.Y2, 70);
TPA := MergeATPA(aTPA);
FindColorsTolerance(TPA1, 986117, B.X1, B.Y1, B.X2, B.Y2, 24);//shadow
bmp := CreateBitmap(B.X2-B.X1+2, B.Y2-B.Y1+2);
OffsetTPA(TPA, Point(-B.X1, -B.Y1));
OffsetTPA(TPA1, Point(-B.X1, -B.Y1));
FastDrawClear(bmp, 0);
DrawTPABitmap(bmp, TPA, clRed);
DrawTPABitmap(bmp, TPA1, clPurple);
ocr_FilterUpTextByCharacteristics(GetMufasaBitmap(bmp));
GetbitmapSize(bmp,w,h);
SetTargetBitmap(bmp); // new target for findcolorstolerance.
findcolorstolerance(TPA, clRed, 0, 0, w-1,h-1, 0);
ATPA := SplitTPAEx(TPA, 15, 2);
L := High(ATPA);
SortATPAFromFirstPointY(ATPA, Point(w/2,0));
SetArrayLength(Result, Length(ATPA));
Result[0].BigBox := BigBox;
for i := 0 to high(ATPA) do
begin
TPA := ATPA[i];
tempatpa := SplitTPAEx(TPA, 1, 10); // Split one into characters
SortATPAFromFirstPointX(tempatpa, Point(0, 0));
Result[i].Str := GetTextATPA(tempatpa, 5, 'UpCharsEx');
BB := GetTPABounds(ATPA[i]);
Result[i].Bounds := IntToBox(BB.X1+B.X1, BB.Y1+B.Y1, BB.X2+B.X1, BB.Y2+B.Y1);
setlength(tempatpa,0);
setlength(TPA,0);
end;
ColorToleranceSpeed(cts);
SetImageTarget(target);
FreeBitmap(bmp);
end;