Results 1 to 17 of 17

Thread: Reverse FindBitmapToleranceIn

  1. #1
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default Reverse FindBitmapToleranceIn

    Heya.
    Is there an easy way, to make Functions like
    FindBitmapToleranceIn,
    FindColor and
    FindColorTolerance
    to search from the lower right corner to the upper left corner ?

    ~caused

  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    PHP Code:
    function FindColorSpiral(var xyIntegercolorxsysxeyeInteger): Boolean;
    Find color in box specified by xsysxeye but start from x,y.

    function 
    FindColorSpiralTolerance(var xyIntegercolorxsysxeyeIntegerToleranceInteger): Boolean;
    Works like the regular FindColorSpiral but with a tolerance parameter for finding any similar colorTolerance is used to find a color in range of the color you are looking for. The greater color range you wantthe higher the tolerance parameter should be
    For the last one
    PHP Code:
    function FindBitmapSpiral(bitmapInteger; var xyIntegerx1y1x2y2Integer): Boolean;
    Search for the bitmap in coordinates specified by x1y1x2y2 starting from xyBitmap contains handle to bitmap generated by LoadBitmap

  3. #3
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Thanks Nauman, but i would need a function that works like the functions i mentioned, not scanning in a spirals, but vertically.

  4. #4
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Yeah, so if you wanted to start from the lower right corner, then you would use a cord in the lower right corner, as it starts from that point.
    If your not happy with that then the answer is no.

  5. #5
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    But it searches in spirals, doesnt it ?_?.

    I'd need to search like that:
    x= pixel o= searched

    xxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxx
    xxxxxxxxooooooooo

    I think find spiral color does something like:

    xxxxxxxxxxxxxxxoo
    xxxxxxxxxxxxooooo
    xxxxxxxxxxooooooo
    xxxxxxxxooooooooo


    ~caused

  6. #6
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    function FindColorSpiral(var x, y: Integer; color, xs, ys, xe, ye: Integer): Boolean;

    notice the xs, ys, we, ye? this is where you can edit to create a box on the screen for you to search.

    to make it search from one side to the other you can simply start the search at the farthest left point by adjusting the x and y value.
    “Ignorance, the root and the stem of every evil.”

  7. #7
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    No, I dont think you understood me yet xD....
    so...

    Example 100x100 image.
    I need a function that first scans from:
    -- x cord ---- y cord
    1. 100to0 | 100
    2. 100to0 | 99
    3. 100to0 | 98
    4. 100to0 | 97
    ...
    100. 100to0 | 1


    Hope that makes it clear =).

    ~caused

  8. #8
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Not possible with bitmapfinding..
    With color finding you can just do FindColorsTolerance, and after that ReverseTPA(TPA); Should do the trick.
    Verrekte Koekwous

  9. #9
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Unless he doesn't mind slowdowns.
    In theory, repeatedly searching from the point found onwards until it didn't find anything would result in finding the last bitmap.
    Alternatively, setting search area to very bottom right then incrementing it after each unsuccessful search should do it.
    Then the only problem exists in that if there are two on the same line, it may miss the latter one. This would depend on if the search area was expanded by 1 horizontally each time then one vertically and resets the x search area (for second option). For the first option, since there's no FindBitmapSkipBox or the like, you would have to each drop down a line after finding one to ensure it doesn't re-find the same one, thus possibly missing one further to the right of it. The way around this would be to perform a search for the rest of that line first then go onto the next line, but unsure as to the success of this.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  10. #10
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Quote Originally Posted by mixster View Post
    Unless he doesn't mind slowdowns.
    In theory, repeatedly searching from the point found onwards until it didn't find anything would result in finding the last bitmap.
    Thats what I'm doing now =).

    Thanks for your replies

  11. #11
    Join Date
    Dec 2008
    Location
    In a galaxy far, far away...
    Posts
    584
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Why don't you just create a downto loop and enter coords starting from lower right decreasing to top left?



    ~NS

  12. #12
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    just whiped this up
    try it
    SCAR Code:
    FindColorReverse(var x, y: Integer; Color: Integer): Boolean;
    var
      i, j: Integer;
    begin
      for i:=MSY2-1 downto MSY1 do
      begin
        for j:=MSX2-1 downto MSX1 do
        begin
          Result:= FindColor(x, y, Color, j, i, MSX2, MSY2);
          if Result then break;
        end;
        if Result then break;
      end;
    end;

    ~shut

  13. #13
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Thanks shuttle U. I Saved that to my include files i made for "advanced" colorfinding .

    It's slow, but does the job : ). Though, for my purpose i can skip 10 pixels all the time, to make it faster, that way i got the function i have made pretty fast.

    I'll try yours later =). Thanks again!

    ~caused

    /E: I Think you could make it more efficient, if you'd count MSX2 -1, after every loop, that way, it would only search 1 pixel a time, not the whole row from "current position" to end.
    Last edited by caused; 07-04-2009 at 06:11 AM.

  14. #14
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by caused View Post
    Thanks shuttle U. I Saved that to my include files i made for "advanced" colorfinding .

    It's slow, but does the job : ). Though, for my purpose i can skip 10 pixels all the time, to make it faster, that way i got the function i have made pretty fast.

    I'll try yours later =). Thanks again!

    ~caused
    if you want it to skip 10 at a time then do this
    SCAR Code:
    FindColorReverse(var x, y: Integer; Color: Integer): Boolean;
    var
      i, j: Integer;
    begin
      for i:=MSY2-1 downto MSY1 do
      begin
        for j:=MSX2-1 downto MSX1 do
        begin
          Result:= FindColor(x, y, Color, j, i, MSX2, MSY2);
          if Result then break;
          j:= j - 9;
        end;
        if Result then break;
      end;
    end;


    ~shut

  15. #15
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Thanks!, yeah i figured something similar out, and also edited my post above with another Idea to make it quicker =)

  16. #16
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    using your other idea
    SCAR Code:
    FindColorReverse(var x, y: Integer; Color: Integer): Boolean;
    var
      i, j: Integer;
    begin
      for i:=MSY2 downto MSY1 do
      begin
        for j:=MSX2 downto MSX1 do
        begin
          Result:= (GetColor(j, i) = Color);
          if Result then
          begin
            x:= j;
            y:= i;
            break;
          end;
        end;
        if Result then break;
      end;
    end;

    ~shut

  17. #17
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Oh, yeah, that does the Job.

    Thanks for the effort, Shuttleu! =)

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
  •