Results 1 to 6 of 6

Thread: getting and changing pixel colors

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    14

    Question

    is there any way to check in a picbox if a pixel is painted over more than once and then change the color?

  2. #2
    Guest
    Use can use GetPixel and SetPixel API's to read and draw pixels.
    Code:
    Private Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
    Private Declare Function SetPixel Lib "gdi32" Alias "SetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
    Usage
    Code:
    'Get a Pixel
    lColour = GetPixel(Picture1.hDC, 5, 5)
    
    'Draw a Pixel
    SetPixel(Picture1.hDC, 5, 5)

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    14

    more help

    how do i check if a pixel has been painted over more than once?

  4. #4
    Guest
    You would have to have a timer constantly monitoring it. for example sake, let's assume the Pixel should normally be coloured blue.
    Code:
    Private Sub Timer1_Timer()
        lColour = GetPixel(Picture1.hDC, 5, 5)
        If lColour <> vbBlue Then   '<--the colour has changed
    End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    14

    Angry No One?

    No one knows how to check if a pixel has been painted over more than once?

  6. #6
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Silvertine, the code that Megatron gave you is the best you can have for this. There's no better way. Sorry.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

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