So I've been away from the scene for a while, but I'm making an new script.
Is there a way to find all instances of the specified bitmap in a certain area?

So I've been away from the scene for a while, but I'm making an new script.
Is there a way to find all instances of the specified bitmap in a certain area?
Hmm...
as in...
?SCAR Code:var
BMPs: Array[0..1] of Integer;
x, y: Integer;
begin
for I := 0 to High(BMPs) do
begin
if (FindBitmapToleranceIn(BMPs, x, y, MSx1, MSy1, MSx2, MSy2, 10)) then
....
end;
end;
or counting how many times a bitmap is in an area?

Yeah, counting how many times its in an area.
{************************************************* ******************************
function CountItemsIn(Area, ItemType: string; Item: Integer; Tol: TIntegerArray): Integer;
By: masquerader modified by ZephyrsFury
Description: Counts the number of items found within the Area. (Does not count stacks)
Parameters:
Area - 'inv', 'shop', 'bank', 'trade', 'your trade'.
ItemType - 'dtm', 'bmp', 'color', 'bmpmask'.
Item - name/value of your dtm/bmp/color/bmpmask.
Tol - 'dtm' - [] (dtm's can't have tolerance).
'bmp' - [BMPTol].
'color' - [COLOUR Tol].
'bmpmask' - [BMPTol, ContourTol].
************************************************** *****************************}
or
{************************************************* ******************************
function CountItemsArea(area: String): Integer;
By: masquerader
Description: Counts items in a specified area. (Doesn't count stacks)
************************************************** *****************************}
if this isnt what you're loooking for, check out Amounts.scar for inspiration
Project: Welcome To Rainbow
SCAR Code:Program New;
{.include SRL\SRL.scar}
Var
TheBMP : Integer;
Function CountBMPs(BMP, Tol : Integer): Integer;
Var
i, Total : Integer;
x, y : Integer;
Box : Array [1..28] Of TBox;
Begin
GameTab(4);
For i := 1 To 28 Do
Begin
Box[i] := InvBox(i);
If FindBitmapToleranceIn(BMP, x, y, Box[i].x1, Box[i].y1, Box[i].x2, Box[i].y2, Tol) Then Inc(Total);
End;
Result := Total;
FreeBitmap(BMP);
End;
Begin
SetupSRL;
TheBMP := BitmapFromString(32, 29, 'beNq1ltlKG1EYx5038GUEBfGmD' +
'9FeeedFUJGQWquEGK1a95CqdUuN+1qXGhuNcWlsCpoK2grFx/Ennz' +
'mcnpmTGNThzzDMzPl96/lmysoKHo5dTzzuITMjn+Kjo3OfxxYmxpc' +
'mJzkvT0+tz3zZiMefZuWejMK+ckNYWY3FMLE5N7uzuLi7vFRiaA8+' +
'u8k2tTQ1BQOBcMu7rra23lBooLPDbsKRbDwejsgY6SKWvbW11NZWe' +
'vfbq5oaG58MlwQHuL/5NZtOnyaTkLnmorP1vSUEh/SikuDJjXUhJ1' +
'ZXri7Oz1IpAqmurPQy4VA7KR8ho6JwwaLthXkp7q/jI262+v2efEW' +
'mPVgiHYIg4BWushay8hwZLXSZzRIOy6sqKgwTgnWTbXBuIt4U8sTw' +
'EO79vfydOdjnJn31P98B6/YZGXwdzmv4Q0o5HycSuZ9ntzc35z9Oe' +
'Yc6Gnx3NhTHcF6MIpYQNaiLTObf9fWfXI7889Qz+UYqdD8N5+VNPC' +
'FenKer6Rycp3ny5fBoTp2sV9CdGYGL8+wvtiRb4OT7Xr6LvDeXIh/' +
'ubKv2M/g6HBoFJTmMFB7lh5518giZ7hK+cthwXsGpqTgfi0bHBweL' +
'TjbI9IDw9RD0WkhNBS7OM7L8Pl9DXV1h/lDXh0h3t8EXE+7MACcbU' +
'lmGJ60eqK8vwB/p6zWk8z0zg/Mkh4HMWGY4ixVb57D1xvr7ox97PK' +
'X3jMBxHj6PiLov3N4TDDIzQ81vbXxqRA9MRSKUCedJlEiZcAfITV4' +
'QPlFggkAsk9khUiolVoiFtXyGEMulLoY5rnkqZMQFgk+hbSHIGKFe' +
'9IMeiG5It6WbQ/hPiWvfvLbxjcK5M4YVQjPEC4gQmhsbi33cHb09p' +
'P1U0jjbRGYe/a/iSCC6FWkVJJ82QkOkkT1Ly5Gx0v+CHr5EYkK3Iq' +
'PmWX/kXuLP8FmPO2H41yY=');
CountBMPs(TheBMP, 10);
End.
Something like that?
Ce ne sont que des gueux

Well, it's not a script for runescape, so if that's the only way, I guess I'm going to have to configure it myself...
No function like "FindBitmapsIn"?![]()
Depending on how the bitmaps are laid out, you might be able to count them by repeating FindBitmapIn and moving the search area by changing the coords (right to left, top down, etc). Regrettably, no, there is no FindBitmaps, FindBitmapSkipBox, etc.
This?
SCAR Code:Program New;
{.include SRL\SRL.scar}
Var
TheBMP : Integer;
Function CountBMPs(BMP, Tol, xs, ys, xe, ye, CoordInc : Integer): Integer;
Var
x, y, x1, y1, x2, y2 : Integer;
Total : Integer;
Begin
Repeat
If FindBitmapToleranceIn(BMP, x, y, x1, y1, x2, y2, Tol) Then Inc(Total);
IncEx(x1, CoordInc);
IncEx(y1, CoordInc);
IncEx(x2, CoordInc);
IncEx(y2, CoordInc);
Until((x1 = xs) And (y1 = ys) And (x2 = xe) And (y2 = ye));
Result := Total;
FreeBitmap(BMP);
End;
Begin
SetupSRL;
TheBMP := BitmapFromString(32, 29, 'beNq1ltlKG1EYx5038GUEBfGmD' +
'9FeeedFUJGQWquEGK1a95CqdUuN+1qXGhuNcWlsCpoK2grFx/Ennz' +
'mcnpmTGNThzzDMzPl96/lmysoKHo5dTzzuITMjn+Kjo3OfxxYmxpc' +
'mJzkvT0+tz3zZiMefZuWejMK+ckNYWY3FMLE5N7uzuLi7vFRiaA8+' +
'u8k2tTQ1BQOBcMu7rra23lBooLPDbsKRbDwejsgY6SKWvbW11NZWe' +
'vfbq5oaG58MlwQHuL/5NZtOnyaTkLnmorP1vSUEh/SikuDJjXUhJ1' +
'ZXri7Oz1IpAqmurPQy4VA7KR8ho6JwwaLthXkp7q/jI262+v2efEW' +
'mPVgiHYIg4BWushay8hwZLXSZzRIOy6sqKgwTgnWTbXBuIt4U8sTw' +
'EO79vfydOdjnJn31P98B6/YZGXwdzmv4Q0o5HycSuZ9ntzc35z9Oe' +
'Yc6Gnx3NhTHcF6MIpYQNaiLTObf9fWfXI7889Qz+UYqdD8N5+VNPC' +
'FenKer6Rycp3ny5fBoTp2sV9CdGYGL8+wvtiRb4OT7Xr6LvDeXIh/' +
'ubKv2M/g6HBoFJTmMFB7lh5518giZ7hK+cthwXsGpqTgfi0bHBweL' +
'TjbI9IDw9RD0WkhNBS7OM7L8Pl9DXV1h/lDXh0h3t8EXE+7MACcbU' +
'lmGJ60eqK8vwB/p6zWk8z0zg/Mkh4HMWGY4ixVb57D1xvr7ox97PK' +
'X3jMBxHj6PiLov3N4TDDIzQ81vbXxqRA9MRSKUCedJlEiZcAfITV4' +
'QPlFggkAsk9khUiolVoiFtXyGEMulLoY5rnkqZMQFgk+hbSHIGKFe' +
'9IMeiG5It6WbQ/hPiWvfvLbxjcK5M4YVQjPEC4gQmhsbi33cHb09p' +
'P1U0jjbRGYe/a/iSCC6FWkVJJ82QkOkkT1Ly5Gx0v+CHr5EYkK3Iq' +
'PmWX/kXuLP8FmPO2H41yY=');
CountBMPs(TheBMP, 10, 0, 0, 1280, 1024, 10);
End.
Ce ne sont que des gueux
Here you go, tested and it works fine.
SCAR Code:function FindBitmapsIn(bmp, x1, y1, x2, y2, Tol: integer): TPointArray;
var
x, y, bitmap, w, h, L, R, G, B: integer;
begin
w := x2 - x1;
h := y2 - y1;
bitmap := BitmapFromString(w, h, '');
CopyClientToBitmap(bitmap, x1, y1, x2, y2);
SetTargetBitmap(bitmap);
while FindBitmapToleranceIn(bmp, x, y, 0, 0, w, h, Tol) do
begin
try
if PointInTPA(Point(x, y), Result) then Break;
except end;
SetLength(Result, L+1);
Result[L] := Point(x, y);
Inc(L);
ColortoRGB(FastGetPixel(bitmap, x, y), R, G, B);
FastSetPixel(bitmap, x, y, RGBtoColor(iAbs(R-255), iAbs(G-255), iAbs(B-255)));
end;
FreeBitmap(bitmap);
ResetDc;
end;
As long as you dont use an obnoxious tolerance like 100 it should work fine.

sweet thanks!
I'll let you know how it goes...
EDIT: When I call the function, it crashes SCAR :/ I still have 3.15b. Should I change to the 3.20 beta?
EDIT: I did some testing - it crashes at
SCAR Code:if PointInTPA(Point(x, y), Result) then Break;
Do you need tolerance?

Uh, no; I don't think so.
I didn't test that part, I just threw it in as a failsafe, because it's possible to get an infinite loop if something stuffs up, just take it out. But If you insist on having a failsafe you could add something like
somewhere in there.SCAR Code:if L > 50 then Break;
Edit: The reason it's stuffing up is probably because the result TPA length is 0 the first time the while loop runs. You could just add a SetLength(Result, 1); at the beginning of the function, and a SetLength(Result, L); at the end of the function.
Or at the beginning of the while loop you could add
Or you could just throw a try except around it, which is probably the best option.SCAR Code:if Length(Result) < 1 then SetLength(Result, 1);
I'll just edit my previous post.

Sweet; It works
Thanks, I really appreciate it
There are currently 1 users browsing this thread. (0 members and 1 guests)