CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    19

    Compare the colour on 2 images?

    I have 2 images on a Picture Box. I need to compare if there are similar colours (pixel values) existing on both pictures, for the same coordinate location. How do I do this?

    dev.


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Compare the colour on 2 images?

    You can use the GetPixel API to do that, this will return the color of a specific pixel, of a specific DC (deviceconext, like a picturebox, screen,...)

    private Declare Function GetPixel Lib "gdi32" (byval hdc as long, byval x as Long, byval y as Long) as Long
    private Sub Command1_Click()
    Dim Pix1 as Long, Pix2 as Long
    Pix1 = GetPixel(Picture1.hdc,10,10)
    Pix2 = GetPixel(Picture2.hdc,10,10)
    If Pix1 <> Pix2 then MsgBox "Pixels have different color"
    End Sub



    This code will check pixel at location 10,10 of the two pictureboxes and compare them

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

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

Featured