SRL Archive - OSR Help

Bitmap Question


kitchenrange

2010-12-21 00:35:53

I completely understand the usage of FindBitmapIn, but my question is how I would go about searching the same area for a large lists of bitmaps. Is there any way to create an array of bitmaps?

I thought maybe I could go with setting an array of integers and setting their fields? as each bitmap. Im thinking that would only save the integer value of the bitmap to the array though and that it would be indistinguishable from any other integer of the same value.

I have the x and y values I want to search between but i dont want to retype

if FindBitmapIn(blah blah) then
something
if FindBitmapIn(blah blah2) then
same thing

when the only thing changing is the bitmap name.

KingKong

2010-12-21 02:03:47

I think it will work, but the downside is that you still have to define each bitmap, eg:

var
bitmap: arrary [0..2] of Integer;
begin
bitmap[0] := bitmapfromstring(blahblahblah);
bitmap[1] := bitmapfromstring(blahblah);
bitmap[2] := bitmapfromstring(blah);
end.

TomTuff

2010-12-21 02:20:40

It's sloppy, but this should work:

function FindAllBitmapsIn(Bitmaps: Array of TVariantArray; xs, ys, xe, ye, Tol: Integer): Boolean;
var
TheBMP, i, x, y: Integer;
begin
for i := 0 to High(Bitmaps) do
begin
TheBMP := BitmapFromString(Bitmaps[i][0], Bitmaps[i][1], Bitmaps[i][2]);
if (FindBitmapToleranceIn(TheBMP, x, y, xs, ys, xe, ye, Tol)) then
begin
if (i = High(Bitmaps))then
begin
Result := True;
end else Continue;
end else
begin
Result := False;
Break;
end;
end;
FreeBitmap(TheBMP);
end;

here's how it would work:

function ExampleofFindAllBitmapsIn: Boolean;
var
ATVA: Array of TVariantArray;
begin
ATVA := ([[[5], [5], ['1234bvzas9d87']], [[3], [4], ['asdfbasvasdf9384']]]);
Result := FindAllBitmapsIn(ATVA, 18, 24, 853, 790, 18);
end;

so in each TVariantArray, the first part is the width, second is the height, and the 3rd is that string.

Make sense? :)

Edit: There should be a FreeBitmap at the end of the finding function…

Wanted

2010-12-21 04:11:39

SCAR has some FindBitmaps functions but it only finds multiple instances of the same bitmap.

function FindBitmaps(Bitmap: Integer; var Points: TPointArray; xs, ys, xe, ye: Integer): Boolean;
Returns the coordinates of all instances of the entered Bitmap found in the search area in the Points array.

function FindBitmapsTolerance(Bitmap: Integer; var Points: TPointArray; xs, ys, xe, ye, Tol: Integer): Boolean;
Returns the coordinates of all instances of the entered Bitmap found with tolerance in the search area in the Points array.

function FindTransparentBitmaps(Bitmap: Integer; var Points: TPointArray; TranspCol, xs, ys, xe, ye, Tol: Integer): Boolean;
Returns the coordinates of all instances of the entered Bitmap found in the search area in the Points array. Pixels on the search Bitmap with the color defined by TranspCol will be skipped in the search.

function FindTransparentBitmapsTolerance(Bitmap: Integer; var Points: TPointArray; TranspCol, xs, ys, xe, ye, Tol: Integer): Boolean;
Returns the coordinates of all instances of the entered Bitmap found with tolerance in the search area in the Points array. Pixels on the search Bitmap with the color defined by TranspCol will be skipped in the search.

function CountBitmap(Bitmap: Integer; xs, ys, xe, ye: Integer): Integer;
Counts the number of instances of the entered Bitmap found in the search area.

function CountBitmapTolerance(Bitmap: Integer; xs, ys, xe, ye, Tol: Integer): Integer;
Counts the number of instances of the entered Bitmap found with tolerance in the search area.

function CountTransparentBitmap(Bitmap: Integer; TranspCol, xs, ys, xe, ye: Integer): Integer;
Counts the number of instances of the entered Bitmap found in the search area. Pixels on the search Bitmap with the color defined by TranspCol will be skipped in the search.

function CountTransparentBitmapTolerance(Bitmap: Integer; TranspCol, xs, ys, xe, ye, Tol: Integer): Integer;
Counts the number of instances of the entered Bitmap found with tolerance in the search area. Pixels on the search Bitmap with the color defined by TranspCol will be skipped in the search.

kitchenrange

2010-12-21 15:12:18

From: kongking
I think it will work, but the downside is that you still have to define each bitmap, eg:

var
bitmap: arrary [0..2] of Integer;
begin
bitmap[0] := bitmapfromstring(blahblahblah);
bitmap[1] := bitmapfromstring(blahblah);
bitmap[2] := bitmapfromstring(blah);
end.


This i understand and would be able to implement easily. I guess that is as good as its gonna get if I want the script completely local.


Thanks TomTuff for the function, I think that will be enough information for me to make mine.