I'm having some trouble counting bitmaps within a specified X/Y region and I've tried everything I could think of, searched the forums for hours on end and still to no avail.
1. I use Simba, not SCAR
2. This is not for Runescape
Here is a method by lordsaturn:
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;
Maybe all I simply need is the Simba-equivalent to SCAR's 'ResetDc' method. Even with commenting out ResetDc I still have a flood of un-freed bitmaps, and to convert the result from this method to an integer I simply use something like this in another method: (This is just an example, not using real values)
Simba Code:
BitmapCount := High(FindBitmapsIn(BitMapID,500,300,600,400,25)):
It's probably an obvious problem and an easy fix to most of you, but I'm still learning as I go so any ideas you can throw my way would be much appreciated.