Results 1 to 11 of 11

Thread: Find All Colors

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

    Default Find All Colors

    Hey there,
    Is there an easy way to write a function that results All Colors of the Client Window ?

    I Could use GetColors(..). To Scan every single Point for Colors, and than use:
    for....
    -> copy colors to some other array, if color doesnt exist in other array
    ...

    But thats quite a performance killer.

    Anyone has a better Idea : D. I'd be glad =):


    ~caused

  2. #2
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    ColorToleranceSpeed(1);
    FindColors(TPA, 9497599, x1, y1, x2, y2, 412);
    Last edited by noidea; 07-15-2009 at 11:26 PM.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

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

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

    Default

    //EDIT.. Eww.thats right, shuttle... That only finds a specific color

  5. #5
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by caused View Post
    //EDIT.. Eww.thats right, shuttle... That only finds a specific color
    No..

    That'll find every colour afaik. Its CTS1 with 412 tolerance (Thats like every colour)
    Then you go throught the array it spits out.

    Try the edit I just made..

    is this what you're looking for?

    ColorToleranceSpeed(1);
    FindColors(TPA, 9497599, x1, y1, x2, y2, 412);
    TIA := GetColors(TPA);
    For i := 0 to GetArrayLength(TPA) - 1 do
    ...
    Last edited by noidea; 07-15-2009 at 11:30 PM.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

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

    Default

    try this
    SCAR Code:
    function GetAllColors: TIntegerArray;
    var
      Hieght, Width, x, y: Integer;
    begin
      GetClientDimensions(Width, Hieght);
      for x:=1 to Width do
        for y:=1 to Hieght do
        begin
          SetArrayLength(Result, High(Result)+1);
          Result[x*y]:= GetColor(x, y);
        end;
    end;
    i havent tried it yet but it shouild work

    ~shut

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

    Default

    I only want one array as result, that inclues all colors of the client window.

    But every color only once.

    Im using "Colors := GetBitmapAreaColors(0,0,xw-20,xh-20);" now : D... Than i will write the colors without duplicates into another TIntegerarray.

    ~caused

  8. #8
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    SCAR Code:
    {*******************************************************************************
    function GetColorsBox(x1, y1, x2, y2: Integer; ClearSameColors: Boolean): TIntegerArray;
    By: Rasta Magician
    Description: Returns an array of all colors within box ((x1, y1), (x2, y2)).
    If ClearSameColors is set to True, all duplicate colors will be deleted.
    *******************************************************************************}

    SCAR Code:
    GetClientDimensions(w, h);
      TIA := GetColorsBox(0, 0, w, h, true);

    http://www.villavu.com/repositories/...ore/Color.scar

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  9. #9
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    SCAR Code:
    {.include srl/srl.scar}

    var
      v : TPointArray;
      TIA: Array [0..1] of TIntegerArray;
      i: Integer;
    begin
      setupsrl;
      ColorToleranceSpeed(1);
      FindColorsTolerance(v, 9497599, 0, 0, 656, 122, 412);
      //DebugTPA(v, '');
      TIA[0] := GetColors(v);
      TIA[1] := [0];
      for i := 0 to GetArrayLength(TIA[0]) - 1 do
        for i := 0 to GetArrayLength(TIA[1]) - 1 do
          if TIA[0][i] = TIA[1][i] then
          begin
            writeln('Same colours! Colour: '+inttostr(TIA[0][i]));
            exit;
          end;
    end.

    Something like this XD ?
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  10. #10
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}

    const
      x1 = 0;
      y1 = 0;
      x2 = 1600;
      y2 = 900;

    var
      i, h : integer;
      TIA : TIntegerArray;
      TPA : TPointArray;
     
    begin
      TPA := TPAFromBox(IntToBox(x1, y1, x2, y2));
      TIA := GetColors(TPA);
      //ClearSameIntegers(TIA);
      h := high(TIA);
      for i := 0 to h do
        Writeln(IntToStr(TPA[i].x) + ', ' + IntToStr(TPA[i].y) + ': ' + IntToStr(TIA[i]));
    end.

    You can do a ClearSameIntegers if you want to not show duplicates (uncomment the line before TIA := GetColors(TPA).
    Last edited by Da 0wner; 07-15-2009 at 11:40 PM.

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

    Default

    Quote Originally Posted by Da 0wner View Post
    SCAR Code:
    program New;
    {.include SRL/SRL.scar}

    const
      x1 = 0;
      y1 = 0;
      x2 = 1600;
      y2 = 900;

    var
      i, h : integer;
      TIA : TIntegerArray;
      TPA : TPointArray;
     
    begin
      TPA := TPAFromBox(IntToBox(x1, y1, x2, y2));
      TIA := GetColors(TPA);
      //ClearSameIntegers(TIA);
      h := high(TIA);
      for i := 0 to h do
        Writeln(IntToStr(TPA[i].x) + ', ' + IntToStr(TPA[i].y) + ': ' + IntToStr(TIA[i]));
    end.

    You can do a ClearSameIntegers if you want to not show duplicates (uncomment the line before TIA := GetColors(TPA).
    I just screwed my own method and use yours now : D. Thanks ALOT @ everyone! =)

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
  •