Results 1 to 5 of 5

Thread: Find Pixel Position

  1. #1

    Thread Starter
    Addicted Member -SUBS-Lenos's Avatar
    Join Date
    Sep 2005

    Find Pixel Position

    how do I find the position of a certain color pixel red for instance?

  2. #2
    Fanatic Member
    Join Date
    Aug 2005
    South Africa

    Re: Find Pixel Position

    I'm not sure if it's the best way to do this but you could use the GetPixel API in a loop until you find the pixel that is the colour you want, record its position and then continue searching for more instances of it
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  3. #3

    Thread Starter
    Addicted Member -SUBS-Lenos's Avatar
    Join Date
    Sep 2005

    Re: Find Pixel Position

    Thats really slow

  4. #4
    Addicted Member
    Join Date
    Apr 2006

    Re: Find Pixel Position

    Hey -SUBS-Lenos,

    I did a little searching, and it seems a faster way is using the GetDiBits() function. I've never used it myself. But a search of this forum turned up a bunch of matches.

    Hope this helps.

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

  5. #5
    Addicted Member Jazz00006's Avatar
    Join Date
    Feb 2006

    Re: Find Pixel Position

    VB Code:
    1. Public Function TestColor(Colortest As Long) As Boolean
    2.     Dim X As Long, Y As Long, test As Long, wndrect As RECT
    3.     GetWindowRect SelWND, wndrect
    4.     test = GetDC(SelWND)
    5.     For Y = 0 To (wndrect.Bottom - wndrect.Top)
    6.         For X = 0 To (wndrect.Right - wndrect.Left)
    7.             If GetPixel(test, X, Y) = Colortest Then
    8.                 TestColor = True
    9.                 msgbox "Colour Found at " & X & "," & Y
    10.                 Exit Function
    11.             End If
    12.         Next
    13.     Next
    14.     TestColor = False
    15. End Function

    Just get the API's for the GetPixel and SelWND (ill post them later if i can find them)

Posting Permissions

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

Click Here to Expand Forum to Full Width