Click to See Complete Forum and Search --> : Compare the colour on 2 images?


dev
August 22nd, 2001, 12:41 AM
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.

Cakkie
August 22nd, 2001, 05:54 AM
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
slisse@planetinternet.be

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