Why does this give me out of range error at Line 24? I've already set the length -__- I even tried doing SetLength(....., (W*H) + 1);
Basically I'm trying to dynamically make fonts.. It grabs all colours from a box (the box around the Max uptext).. Stores in a T2DPointArray along with the colours in a T2DIntegerArray..
Does this once for each angle.. N, S, E, W.. Then match them.. if the colours are NOT the same, set them to 0.. aka black.. thus it should leave only the uptext in the array since those colours don't change.. Then makes a bitmap out of the data which can probably be cropped down to the right size per letter.
I just can't get it to compile..
Simba Code:{$I SRL/srl.Simba}
{$I SRL/SRL/Misc/Debug.Simba}
type
TPAC = record
TPA: T2DPointArray;
TIA: T2DIntegerArray;
end;
Function GetTPACBox(B: TBox): TPAC;
var
Temp: TPAC;
TP: TPoint;
I, J, W, H: Integer;
begin
W:= B.X2 - B.X1;
H:= B.Y2 - B.Y1;
For I:= 0 To H do
For J:= 0 To W do
begin
SetLength(Temp.TPA, Length(Temp.TPA) + 1);
TP:= Point(B.X1 + J, B.Y1 + I);
Temp.TPA[J][I]:= TP;
SetLength(Temp.TIA, Length(Temp.TIA) + 1);
Temp.TIA[J][I]:= GetColor(TP.X, TP.Y);
end;
Result:= Temp;
end;
Procedure GetTextBoxes;
var
Temp: Array of TPAC;
B: TBox;
I, J, K, BMP, W, H: Integer;
TempI: TIntegerArray;
begin
B:= IntToBox(5, 5, 225, 20);
SetLength(Temp, 4);
Temp[0]:= GetTPACBox(B);
MakeCompass('E');
Temp[1]:= GetTPACBox(B);
MakeCompass('S');
Temp[2]:= GetTPACBox(B);
MakeCompass('W');
Temp[3]:= GetTPACBox(B);
W:= B.X2 - B.X1;
H:= B.Y2 - B.Y1;
For I:= 0 To H do
For I:= 0 To W do
if ((Temp[0].TIA[J][I] <> Temp[1].TIA[J][I]) or (Temp[0].TIA[J][I] <> Temp[2].TIA[J][I]) or (Temp[0].TIA[J][I] <> Temp[3].TIA[J][I])) then
begin
Temp[0].TIA[J][I]:= 0;
Temp[1].TIA[J][I]:= 0;
Temp[2].TIA[J][I]:= 0;
Temp[3].TIA[J][I]:= 0;
end;
BMP:= CreateBitmap(W, H);
K:= 0;
For I:= 0 To H do
For J:= 0 To W do
begin
SetLength(TempI, Length(TempI) + 1);
TempI[K]:= Temp[0].TIA[J][I];
Inc(K);
end;
For I:= 0 To H do
For J:= 0 To W do
DrawATPABitmapEx(BMP, Temp[0].TPA, TempI);
DebugBitmap(BMP);
FreeBitmap(BMP);
end;
begin
setupSRL;
GetTextBoxes;
end.








Reply With Quote



