I'm working on something similar at the moment, except that the database builds itself.
program New;
{.include Srl\SRL.scar}
var
UIDB_Net: TPointArray;
procedure UIDB_LoadNet;
var tmpcount,hx,hy:integer;
begin
SetArrayLength(UIDB_Net,506);
repeat
hy:=9;
hx:=hx+1;
repeat
hy:=hy+1;
if (((hx mod 2)=0) or ((hy mod 2)=0)) then
begin
UIDB_Net[tmpcount]:=Point(hx,hy);
Inc(tmpcount);
end;
until hy=31;
until hx=31;
end;
Function InvBox2(i :Integer): TBox;
begin
if (i < 1) or (i > 28) then
begin
srl_Warn('InvBox', 'Incorrect index: ' + IntToStr(i), warn_AllVersions);
exit;
end;
{1 x1 563 y1 213 x2 594 y2 244}
{5 x1 605 y1 249}
Result.x1 :=563+((((i+3)mod 4))*(605-563));
Result.y1 :=213+((((i-1)/4))*(249-213));
Result.x2 := Result.x1+31;
Result.y2 := Result.y1+31;
end;
{*******************************************************************************
function strToIntArrayEx(intArray, Separater : String) : Array of Integer;
By: moparisthebest and modified by Ron
Description: Loads a String into an array of integer. (Example String: '567 389 3234 98342 7998767')
*******************************************************************************}
function strToIntArrayEx(intArray, Separater : String) : Array of Integer;
var
i, spacePos: Integer;
begin
repeat
SetArrayLength(Result, i + 1);
spacePos := Pos(Separater, intArray);
if (not (spacePos = 0)) then
Result[i] := StrToInt(Copy(intArray, 1, spacePos - 1))
else
begin
Result[i] := StrToInt(Copy(intArray, 1, Length(intArray)));
break;
end;
Delete(intArray, 1, spacePos);
i := i + 1;
until (False)
end;
{*******************************************************************************
function strToIntArray(intArray : String) : Array of Integer;
By: moparisthebest and modified by Ron
Description: Refer to strToIntArrayEx.
*******************************************************************************}
function strToIntArray(intArray : String) : Array of Integer;
begin
Result := strToIntArrayEx(intArray, ' ');
end;
{*******************************************************************************
function intArrayToStrEx(intArray : Array of Integer; Separater : String) : String;
By: moparisthebest and modified by Ron
Description: Loads an array of integer into a String. (Example String: '567 389 3234 98342 7998767')
*******************************************************************************}
function intArrayToStrEx(intArray : Array of Integer; Separater : String) : String;
var
i, arrayLength: Integer;
begin
arrayLength := GetArrayLength(intArray);
repeat
Result := Result + IntToStr(intArray[i]);
if (not(i = (arrayLength - 1))) then
Result := Result + Separater;
i := i + 1;
until (i = arrayLength)
end;
{*******************************************************************************
function intArrayToStr(intArray : Array of Integer) : String;
By: moparisthebest and modified by Ron
Description: Refer to intArrayToStrEx.
*******************************************************************************}
function intArrayToStr(intArray : Array of Integer) : String;
begin
Result := intArrayToStrEx(intArray, ' ');
end;
function CreateBL(Area:string; Slot:integer): TIntegerArray;
var SlotBox:TBox;
i,tmpAL:integer;
begin
case lowercase(Area) of
'inv': SlotBox:= InvBox2(Slot);
'bank': SlotBox:= BankIndexToMSBox(Slot);
end;
tmpAL:=1;
SetArrayLength(result,tmpAL+1);
for i:=0 to 505 do
begin
if getcolor(UIDB_Net[i].x+SlotBox.x1,UIDB_Net[i].y+SlotBox.y1)=65536 then
begin
result[tmpAL]:=i;
Inc(tmpAL);
SetArrayLength(result,tmpAL+1);
end;
end;
SetArrayLength(result,tmpAL);
result[0]:=tmpAL-1;
end;
function CompareBL(First,Second:TIntegerArray):boolean;
var i:integer;
begin
if First[0]<> Second[0] then exit;
for i:=1 to First[0] do
begin
if First[i] <> Second[i] then exit;
end;
result:=true;
end;
var c,t,MyBMP:integer;
MyBL:TIntegerArray;
begin
UIDB_LoadNet;
MyBmp:= LoadBitmap(AppPath+'\UIDB\BmpTest2.bmp');
SetTargetBitmap(MyBmp);
for c:=1 to 26 do
begin
MyBL:=CreateBL('inv',c);
WriteINI('Item'+inttostr(c),'Black', intArrayToStr(MyBL),AppPath+'\UIDB\UIDB.ini');
end;
FreeBitmap(mybmp);
t:=getsystemtime;
if CompareBL( strToIntArray(ReadIni('Item3','Black',AppPath+'\UIDB\UIDB.ini')),
CreateBL('inv',8)) then
writeln('yes');
writeln(inttostr(getsystemtime-t));
end.
Edit: The above use a bmp saved in the scar folder generated with this while I had the first 26 spaces in the inventory with stuff
program New;
var MyBmp,w,h:integer;
begin
GetClientDimensions(w,h);
MyBmp:=BitmapFromString(w,h,'');
CopyClientToBitmap(MyBmp, 0,0,w,h);
SaveBitmap(MyBmp,AppPath+'\UIDB\Bmp'+'Test2'+'.bmp');
end.