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.
Printable View
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.
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