Results 1 to 14 of 14

Thread: Find all the bitmaps in an area?

  1. #1
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Find all the bitmaps in an 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?

  2. #2
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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?

  3. #3
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yeah, counting how many times its in an area.

  4. #4
    Join Date
    Dec 2007
    Location
    Wizzup?'s boat
    Posts
    1,013
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    {************************************************* ******************************
    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

  5. #5
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    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


  6. #6
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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"?

  7. #7
    Join Date
    Feb 2007
    Location
    Toronto, Ontario, Canada
    Posts
    586
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.

  8. #8
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    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


  9. #9
    Join Date
    Mar 2007
    Posts
    1,700
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    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.

  10. #10
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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;

  11. #11
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Do you need tolerance?

  12. #12
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Uh, no; I don't think so.

  13. #13
    Join Date
    Mar 2007
    Posts
    1,700
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by Infintry001 View Post
    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;
    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
    SCAR Code:
    if L > 50 then Break;
    somewhere in there.

    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
    SCAR Code:
    if Length(Result) < 1 then SetLength(Result, 1);
    Or you could just throw a try except around it, which is probably the best option.
    I'll just edit my previous post.

  14. #14
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sweet; It works

    Thanks, I really appreciate it

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Spaming area
    By teamdark6 in forum NOTA
    Replies: 14
    Last Post: 12-21-2008, 03:38 PM
  2. script cant find bitmaps
    By XcanadamanX in forum OSR Help
    Replies: 6
    Last Post: 11-18-2006, 02:26 PM

Posting Permissions

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