Results 1 to 3 of 3

Thread: method to FindColorsTolerance in bitmap?

  1. #1
    Join Date
    Oct 2015
    Location
    Nowhere
    Posts
    134
    Mentioned
    2 Post(s)
    Quoted
    64 Post(s)

    Default method to FindColorsTolerance in bitmap?

    I see there's FindColorsBitmap. How can I search for colors with tolerance? Will I have to create my own method or is there one that I'm missing?

    EDIT: Got an answer in IRC, thanks to Zef. He said to use FastGetPixels & SimilarColors.

    Here's what I made with that incase anyone needs it
    Simba Code:
    function FindColorsToleranceBitmap(bmp:Integer; var retTPA:TPointArray; color, tolerance:Integer):Boolean;
    var
      i, w, h:Integer;
      TIA:TIntegerArray;
      TPA:TPointArray;
    begin
      GetBitmapSize(bmp, w, h);
      TPA := TPAFromBox(intToBox(0, 0, w-1, h-1));
      TIA := fastGetPixels(bmp, TPA);
      for i := 0 to high(TPA)do
        if(SimilarColors(color, TIA[i], tolerance))then
          retTPA.append(TPA[i]);
    end;

  2. #2
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Another way, also used in my essence miner (this is a lot faster):
    Simba Code:
    function FindColorsToleranceBitmap(bmp:Integer; var retTPA:TPointArray; color, tolerance:Integer):Boolean;
    var
      ITarget, w, h : Integer;
    begin
      GetBitmapSize(bmp, w, h);
      ITarget := GetImageTarget;
      SetTargetBitmap(bmp);
      result := FindColorsTolerance(retTPA, 0, 0, w-1, h-1, tolerance);
      SetImageTarget(ITarget);
    end;

    Cheers.
    I made a new script, check it out!.

  3. #3
    Join Date
    Oct 2015
    Location
    Nowhere
    Posts
    134
    Mentioned
    2 Post(s)
    Quoted
    64 Post(s)

    Default

    Thanks! Didn't think I could set target to a bitmap like that

    MUCH faster (over 150ms)

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
  •