|
-
Aug 9th, 1999, 03:44 PM
#1
Thread Starter
Addicted Member
How can I determine if 2 pictures in pictureboxes are identical?
-
Jul 16th, 2003, 03:43 PM
#2
Fanatic Member
Identical as in what? Same file or same picture?
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 16th, 2003, 03:54 PM
#3
If you're reading in from a file or comparing what;s in the ram, a checksum would work well me thinks.
Don't ask me how to do it though,
-
Jul 16th, 2003, 04:01 PM
#4
Fanatic Member
If you comparing against another picture, I would say to check each pixel in both pictures against each other, and if all are the same, then the pictures are equal.
The complexity of implementing this operation depends on the programming language.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
-
Jul 16th, 2003, 05:12 PM
#5
Frenzied Member
you can load it as a string using
VB Code:
Open Filename For Binary As #1
PicString = Space(LOF(1))
Get #1, , PicString
Close #1
do this for both pictures, then do:
VB Code:
If PicString = PicString2 Then
'The same
Else
'Not the same
End If
this should work is the file is the same format and it should work for _any_ format.
if you want to compare a .bmp with a .tga, for example, you have to load them both in an array and check all pixels or do it the slow way: load them into a picturebox (or another dc) and check them using getpixel.
-
Jul 17th, 2003, 06:02 AM
#6
Lively Member
VB Code:
Dim booInvalid
Picture1.Picture = LoadPicture("C:/Image1.jpg") 'Load first image
Picture2.Picture = LoadPicture("C:/Image2.jpg") 'Load second image
Picture1.ScaleMode = 3 'Scale mode set to pixels
Picture2.ScaleMode = 3 'Scale mode set to pixels
'Test the image demensions first
If Picture1.ScaleWidth = Picture2.ScaleWidth and Picture1.ScaleHeight = Picture2.ScaleHeight Then
'Loop through pixel by pixel to see if the pictures match
For X = 0 to Picture1.ScaleWidth
For Y = 0 to Picture1.ScaleHeight
'Check if pixels are equal
If Not GetPixel (Picture1.hDC, X, Y) = GetPixel (Picture2.hDC, X, Y) Then
booInvalid = True 'Set the Invalid flag (Pictures are not equal)
End If
Next
Next
Else
booInvalid = True 'Set the Invalid flag (Pictures are not equal)
End If
'Return response
If booInvalid = True Then
MsgBox "Pictures ARE NOT identical."
Else
MsgBox "Pictures ARE identical.
End If
This will check if two pictures are identical.
-Dylan
Last edited by D.Viddy; Jul 17th, 2003 at 06:06 AM.
-
Jul 17th, 2003, 06:43 AM
#7
Ex-Super Mod'rater
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

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
|