Results 1 to 5 of 5

Thread: Bitmap Question

  1. #1
    Join Date
    Oct 2008
    Posts
    500
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default Bitmap Question

    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.

  2. #2
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    I think it will work, but the downside is that you still have to define each bitmap, eg:
    Simba Code:
    var
      bitmap: arrary [0..2] of Integer;
    begin
      bitmap[0] := bitmapfromstring(blahblahblah);
      bitmap[1] := bitmapfromstring(blahblah);
      bitmap[2] := bitmapfromstring(blah);
    end.

  3. #3
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    It's sloppy, but this should work:
    Simba Code:
    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:
    Simba Code:
    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...
    Last edited by TomTuff; 12-21-2010 at 07:25 AM.

  4. #4
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

    SCAR Code:
    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.

  5. #5
    Join Date
    Oct 2008
    Posts
    500
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by kongking View Post
    I think it will work, but the downside is that you still have to define each bitmap, eg:
    Simba Code:
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •