SRL Archive - Research & Development Lounge

Bmp Counter!


Cazax

2008-02-29 10:08:53

my second function:
function HowManyBmps(bmpname,MaxTol,x1,y1,x2,y2 : Integer) : Integer;
var
x,y,BmpColor :Integer;
BMPs : TPointArray;
begin
BmpColor := AutoColorThis(bmpname,MaxTol,x1,y1,x2,y2);
FindColorsSpiralTolerance(x,y,BMPs,BmpColor,x1,y1,x2,y2,0);
Result := GetArrayLength(BMPs);
end;

The result will be the number of bmps found.

Tootoot222

2008-02-29 10:11:22

why/how would you use this???

Cazax

2008-02-29 10:14:00

From: tootoot222
why/how would you use this???


e.g:
you want to count how many logs did you chopped. Make a bmp and use my function :)

Tootoot222

2008-02-29 10:21:08

ah, i see, it returns how many BMPs there are on screen, ok

you didn't say anything about what it did on the first post though

Cazax

2008-02-29 10:27:29

From: tootoot222
ah, i see, it returns how many BMPs there are on screen, ok

you didn't say anything about what it did on the first post though


K i forgot.

Negaal

2008-02-29 10:33:34

This wouldn't work, you will find total amount of matching pixels. not amount of items.

Cazax

2008-02-29 10:34:56

From: Negaal
This wouldn't work, you will find total amount of matching pixels. not amount of items.


hmm… how can i do that then?

MylesMadness

2008-02-29 10:41:54

As far as I know without knowing where to look impossible. Maybe look at some of the amount functions in srl

Cazax

2008-02-29 10:43:23

From: Mylesmadness
As far as I know without knowing where to look impossible. Maybe look at some of the amount functions in srl


I looked at amount.scar:
{*******************************************************************************
function CountItemsDtm(area: String; dtm: Integer): Integer;
By: masquerader
Description: Counts items in a specified area found with a dtm. (Doesn't count stacks)
*******************************************************************************}

function CountItemsDtm(area: string; dtm: Integer): Integer;
var
coords: TPointArray;
begin
coords := ItemCoordsDtm(area, dtm);
Result := GetArrayLength(coords);
end;

Negaal

2008-02-29 11:19:48

From: cazax
hmm… how can i do that then?

function CountInvColor(Color, tolerance : integer) : integer;
var
i, x, y : integer;
B : TBox;
begin
for i := 1 to 28 do
begin
B := InvBox(I);
if FindColorTolerance(x, y, color, B.X1, B.Y1, B.X2, B.Y2, tolerance) then
Result := Result + 1;
end;
end;

MylesMadness

2008-02-29 11:26:31

I was thinking itemcoordsbmp:
function ItemCoordsBmp(area: string; bmp, tol: Integer): TPointArray;
var
startx, starty, rowsize, colsize, colnumber, rownumber, col, row: Integer;
x1, y1, x2, y2: Integer;
itemx, itemy: Integer;
i: Integer;
begin
SetArrayLength(Result, 0);
if (CheckArea(area)) then
begin
AreaInfo(area, startx, starty, rowsize, colsize, colnumber, rownumber);
for row := 0 to rownumber - 1 do
for col := 0 to colnumber - 1 do
begin
x1 := startx + col * colsize;
y1 := starty + row * rowsize;
x2 := x1 + colsize;
y2 := y1 + rowsize;
if (FindBitmapToleranceIn(bmp, itemx, itemy, x1, y1, x2, y2, tol)) then
begin
i := GetArrayLength(Result);
SetArrayLength(Result, i + 1);
Result[i].x := x1;
Result[i].y := y1;
// writeln(inttostr(x1)+','+inttostr(y1));
end;
end;
end;
end;
Anyway basicly what that does is makes a box around each inv slot so searchs for it in that box and repeats until all the slots are searched