|
-
Mar 23rd, 2005, 06:52 AM
#1
Thread Starter
Member
comparision of images pixel by pixel
How can I Compare Two Images Pixel by Pixel?
-
Mar 23rd, 2005, 07:10 AM
#2
Fanatic Member
Re: comparision of images pixel by pixel
Private Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
for X = 1 to picture1.width
for Y = 1 to picture1.height
if GetPixel(picture1.hdc,x,y) = getpixel(picture2.hdc,x,y) then
end if
next
next
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
-
Mar 23rd, 2005, 07:47 AM
#3
Thread Starter
Member
Re: comparision of images pixel by pixel
The Above Code Is Not Working Properly.
I don't Want to compare two images by its size
I Want to Compare the images to find out that both are identical or not.
Can N E 1 Help Me?
-
Mar 23rd, 2005, 08:34 AM
#4
Fanatic Member
Re: comparision of images pixel by pixel
Load one picture into picture1 control and the other into picture2. Then execute the following function. It loops around all pixels and compares the colour between the two pictures.
VB Code:
Private Function AreBothTheSame() As Boolean
Dim x As Long, y As Long
For x = 1 To picture1.Width
For y = 1 To picture1.Height
If getpixel(picture1.hDC, x, y) <> getpixel(picture2.hDC, x, y) Then
AreBothTheSame = False
Exit Function
End If
Next
Next
AreBothTheSame = True
End Function
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
-
Mar 23rd, 2005, 09:21 AM
#5
Thread Starter
Member
Re: comparision of images pixel by pixel
What I want is.....
when i click on the command button, the message should be displayed containing the information about whether both the images are identicle or not.
where should i write the above code?
-
Mar 23rd, 2005, 09:45 AM
#6
Re: comparision of images pixel by pixel
 Originally Posted by jalzaaal
What I want is.....
when i click on the command button, the message should be displayed containing the information about whether both the images are identicle or not.
where should i write the above code?
Try using that function in a command button using a MsgBox to return whether it's identical or not. The function is comparing the images pixel by pixel and it works.
-
Mar 23rd, 2005, 09:50 AM
#7
Fanatic Member
Re: comparision of images pixel by pixel
Add 2 picture boxes and a button to a form
VB Code:
Option Explicit
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Function AreBothTheSame() As Boolean
Dim x As Long, y As Long
For x = 1 To Picture1.Width
For y = 1 To Picture1.Height
If GetPixel(Picture1.hdc, x, y) <> GetPixel(Picture2.hdc, x, y) Then
AreBothTheSame = False
Exit Function
End If
Next
Next
AreBothTheSame = True
End Function
Private Sub Command1_Click()
If AreBothTheSame() = True Then
MsgBox "Both pictures are identical"
Else
MsgBox "Both pictures are different"
End If
End Sub
Private Sub Form_Load()
Set Picture1 = LoadPicture("c:\out1.jpg")
Set Picture2 = LoadPicture("c:\out2.jpg")
End Sub
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
-
Mar 23rd, 2005, 10:10 AM
#8
Thread Starter
Member
Re: comparision of images pixel by pixel
Ya... The Above Code is working...
You Have solved my Problem
Thank You So Much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|