Results 1 to 9 of 9

Thread: FindBitmapRotated

  1. #1
    Join Date
    Apr 2012
    Posts
    157
    Mentioned
    10 Post(s)
    Quoted
    57 Post(s)

    Default FindBitmapRotated

    Hey Guys,

    I'm having a bit of a hard time finding this function...It's mentioned in the bitmap tutorial. But almost nowhere else..

    Is there something I am missing to access it?

  2. #2
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    I believe you have to use something along the lines of:

    Simba Code:
    var
      Bmp, x, y: Integer;
      i: Extended;

    //...

    for i := 1 to 360 do
    begin
      if FindBitmap(Bmp, x, y) then
      begin
        //...
      end else
        RotateBitmap(Bmp, i);
    end;

    or

    Simba Code:
    var
      Bmp, x, y: Integer;
      i: Extended;

    //...

    i := 0;
    repeat
      if FindBitmap(Bmp, x, y) then
      begin
        //...
      end else
      begin
        IncEx(i, 2);
        RotateBitmap(Bmp, i);
      end;
    end;

    to do what you're looking for.
    Last edited by Runaway; 05-30-2012 at 12:32 AM.

  3. #3
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    FindBitmapRotated was a scar function that is not in simba, the tutorial you were following was probably for scar

  4. #4
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Simba Code:
    Function FindBitmapRotated(var X, var Y: Integer; Bitmap, Tolerance: Integer; Area: TBox): Boolean;
    var
      I: Integer;
    begin
      For I:= 0 To 359 Do
      begin
        Result:= FindBitmapToleranceIn(Bitmap, X, Y, Area.X1, Area.Y1, Area.X2, Area.Y2, Tolerance);
        If Result then
          Break;
        Bitmap:= RotateBitmap(Bitmap, 1);
      end;
    end;

    I'm not on a proper computer to test that but theoretically it should be identical.. I hope :S
    I am Ggzz..
    Hackintosher

  5. #5
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    Simba Code:
    Function FindBitmapRotated(var X, var Y: Integer; Bitmap, Tolerance: Integer; Area: TBox): Boolean;
    var
      I: Integer;
    begin
      For I:= 0 To 359 Do
      begin
        Result:= FindBitmapToleranceIn(Bitmap, X, Y, Area.X1, Area.Y1, Area.X2, Area.Y2, Tolerance);
        If Result then
          Break;
        Bitmap:= RotateBitmap(Bitmap, 1);
      end;
    end;

    I'm not on a proper computer to test that but theoretically it should be identical.. I hope :S
    Btw are angles in degrees or radians?

  6. #6
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by putonajonny View Post
    Btw are angles in degrees or radians?
    RotateBitmap is in degrees, as well as most of the angle-related functions.

  7. #7
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by Runaway View Post
    RotateBitmap is in degrees, as well as most of the angle-related functions.
    in this case in radians

    I don't know if this works with angles != PI/2 * k , because then bitmap looks like:


    ,so black background becomes part of bitmap. It may work ,if bitmap finding function ignores clBlack.

    And every new rotated bitmap is rectangle ,so if you rotate same bitmap multiple times at non 90 degree ,size of canvas will increase geometrically. Run this to understand ,what I'm talking about ,because it's hard to explain in english:
    Simba Code:
    program new;
      {$i srl/srl.simba}
         {$I srl/srl/misc/debug.simba}
         var
         bmp ,a : integer;

    begin
       bmp := CreateBitmap(50,50);
       FastReplaceColor(bmp,0,clred);
       for a:= 0 to 9 do
       begin
            FastReplaceColor(bmp,0,a*2560);
            debugbitmap(bmp);
            wait(1000);
            bmp :=  RotateBitmap(bmp,Radians(30));
       end;
    end.
    Last edited by bg5; 05-31-2012 at 10:23 PM.

  8. #8
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by beginner5 View Post
    in this case in radians

    I don't know if this works with angles != PI/2 * k , because then bitmap looks like:
    Simba ignores black by default unless you settransparent to a different colour. Anything black by default is considered transparent. I thought it was degrees :S Why radians but yeah good idea though.
    I am Ggzz..
    Hackintosher

  9. #9
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    btw.

    If you ever gonna try to iterate same bitmap throught 360 degree
    you will be eaten by
    salad monster:
    Simba Code:
    program new;
      {$i srl/srl.simba}
      {$I srl/srl/misc/debug.simba}
         var
         bmp ,bmp2 ,a : integer;
    begin
       bmp := CreateBitmap(50,50);
       FastReplaceColor(bmp,0,clred);
       for a:= 0 to 170 do
       begin
            FastReplaceColor(bmp,0,a*2560);
            debugbitmap(bmp);
            bmp2 :=  RotateBitmap(bmp,Radians(1));
            Freebitmap(bmp);
            bmp := bmp2;
       end;
    end.

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
  •