[REQUEST] Bare-bone colour picking

Discussion in 'Programming General' started by Blupig, Jan 5, 2008.

[REQUEST] Bare-bone colour picking
  1. Unread #1 - Jan 5, 2008 at 3:00 PM
  2. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    [REQUEST] Bare-bone colour picking

    I've tried to assemble a colour-click program on my own using a mix-up of sources, but can never do it...It would be nice for someone more experienced than me to post a source to help me with the usage of colour clicking. I've already looked at the Jaghax autofighter source by TK, but I was blinded by too many features and complicated aspects of the program. Help please?
     
  3. Unread #2 - Jan 5, 2008 at 11:22 PM
  4. Jazz00006
    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0

    Jazz00006 Apprentice
    Visual Basic Programmers

  5. Unread #3 - Jan 6, 2008 at 11:58 AM
  6. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    [REQUEST] Bare-bone colour picking

    Declarations:
    Code:
    Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, _
        ByVal x As Long, ByVal y As Long) As Long
    Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) _
            As Long
    Private Declare Function ReleaseDC Lib "user32" ( _
    ByVal hwnd As Long, _
    ByVal hdc As Long _
    ) As Long
    
    Private Type COORDS
    x As Integer
    y As Integer
    End Type
    
    FindColor Function:
    Code:
    Private Function FindColor(StartX As Long, StartY As Long, EndX As Long, EndY As Long, Color As Long, Color2 As Long) As COORDS
    
    Dim i As Long, j As Long, n As Long, lDC As Long, CurrentPixel As Long
    lDC = GetWindowDC(0)
        
    For j = StartY To EndY Step 1
        For i = StartX To EndX Step 1
        
            CurrentPixel = GetPixel(lDC, i, j)
            If CurrentPixel = Color1 Then
                FindColor.x = i
                FindColor.y = j
                ReleaseDC 0, lDC
                Exit Function
            ElseIf CurrentPixel = Color2 Then
                FindColor.x = i
                FindColor.y = j
                ReleaseDC 0, lDC
                Exit Function
            End If
        Next i
    Next j
    
    ReleaseDC 0, lDC
    End Function
    Not a sexy spiral like Cruel's but it gets the job done by finding colors in a square/rectange you specify by telling it the coordinates of the top left corner and the bottom right corner of the area. Also, it can be easily converted to become FindColorTolerance. Don't be too negative, I did make this from scratch. :)

    If you decide to use it and have any questions or want to go about adding tolerance just add me on MSN as it's probably easier.
     
  7. Unread #4 - Jan 6, 2008 at 11:30 PM
  8. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    [REQUEST] Bare-bone colour picking

    Nullware you're talking down that peice of code lol.
    Its not that bad, its pretty much what everyone used until cruel released his colour spiral.
     
  9. Unread #5 - Jan 7, 2008 at 12:13 AM
  10. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    [REQUEST] Bare-bone colour picking

    What do you mean?:confused:
     
  11. Unread #6 - Jan 7, 2008 at 12:52 AM
  12. Jazz00006
    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0

    Jazz00006 Apprentice
    Visual Basic Programmers

    [REQUEST] Bare-bone colour picking

    He means to say that it is a nice piece of code, and you are saying it is bad.
     
  13. Unread #7 - Jan 7, 2008 at 8:25 PM
  14. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    [REQUEST] Bare-bone colour picking

    Thanks!:eek:

    I made that on my own from nothing.:D
     
< keygens... | Winsock >

Users viewing this thread
1 guest


 
 
Adblock breaks this site