Re: check this code <URGENT>
This way it is easier to read:
VB Code:
Sub Check()
Dim boomismatch As Boolean
Dim x As Integer
Dim y As Integer
boomismatch = False
For y = 1 To Picture1.Height
For x = 1 To Picture1.Width
If Picture1.Point(x, y) = Picture2.Point(x, y) Then
Picture1.PSet (x, y), RGB(255, 0, 0)
boomismatch = True
Exit For
End If
Next x
If boomismatch = True Then
Exit For
End If
Next y
If boomismatch = True Then
MsgBox "not same"
c = 0
Else
MsgBox "same"
MsgBox Picture1.Name
c = 1
Exit Sub
End If
End Sub
Re: check this code <URGENT>
If you want help you should ask nicely and DON'T SCREAM AT US!!!
Re: check this code <URGENT>
You say you're getting an error.
Maybe you should first test this
VB Code:
If Picture1.Height <> Picture2.Height or Picture1.Width <> Picture2.Width Then
'Not a match, do something
end if
You may can also make that pixel test faster if you set the scalemode on both PictureBoxes to vbPixels.
Re: check this code <URGENT>
Quote:
Originally Posted by baja_yu
This way it is easier to read:
VB Code:
Sub Check()
Dim boomismatch As Boolean
Dim x As Integer
Dim y As Integer
boomismatch = False
For y = 1 To Picture1.Height
For x = 1 To Picture1.Width
If Picture1.Point(x, y) = Picture2.Point(x, y) Then
Picture1.PSet (x, y), RGB(255, 0, 0)
boomismatch = True
Exit For
End If
Next x
If boomismatch = True Then
Exit For
End If
Next y
If boomismatch = True Then
MsgBox "not same"
c = 0
Else
MsgBox "same"
MsgBox Picture1.Name
c = 1
Exit Sub
End If
End Sub
but it gives incorrect results
plz correct it & send it 2 me.
Re: check this code <URGENT>
Ok well, just going through...
VB Code:
Sub Check()
Dim boomismatch As Boolean
Dim x As Integer
Dim y As Integer
boomismatch = False
For y = 1 To Picture1.Height
For x = 1 To Picture1.Width
If Picture1.Point(x, y) = Picture2.Point(x, y) Then
Picture1.PSet (x, y), RGB(255, 0, 0)
Else
boomismatch = True
Exit For
End If
Next x
If boomismatch = True Then
Exit For
End If
Next y
If boomismatch = True Then
MsgBox "not same"
c = 0
Else
MsgBox "same"
MsgBox Picture1.Name
c = 1
Exit Sub
End If
End Sub
Does that do it?
Re: check this code <URGENT>
You're going to get an error if the pics aren't the same size
1 Attachment(s)
Re: check this code <URGENT>
Quote:
Originally Posted by Nove
Ok well, just going through...
VB Code:
Sub Check()
Dim boomismatch As Boolean
Dim x As Integer
Dim y As Integer
boomismatch = False
For y = 1 To Picture1.Height
For x = 1 To Picture1.Width
If Picture1.Point(x, y) = Picture2.Point(x, y) Then
Picture1.PSet (x, y), RGB(255, 0, 0)
Else
boomismatch = True
Exit For
End If
Next x
If boomismatch = True Then
Exit For
End If
Next y
If boomismatch = True Then
MsgBox "not same"
c = 0
Else
MsgBox "same"
MsgBox Picture1.Name
c = 1
Exit Sub
End If
End Sub
Does that do it?
NOT IG GIVES INCORRECT RESULTS
I SEND U PROG TO CHECK, OK
Re: check this code <URGENT>
If you want to check if the images are identical, then the logic is simple:
1. Compare sizes, if different then they are not the same
2. If same size, then loop through all pixels and compare if they are the same color.
3. If at least 1 pair of pixels is not the same color, then the images are not same.
You can implement some sort of flexibility, for instance, allow 1% of pixels to be different.
Re: check this code <URGENT>
Quote:
Originally Posted by baja_yu
If you want to check if the images are identical, then the logic is simple:
1. Compare sizes, if different then they are not the same
2. If same size, then loop through all pixels and compare if they are the same color.
3. If at least 1 pair of pixels is not the same color, then the images are not same.
You can implement some sort of flexibility, for instance, allow 1% of pixels to be different.
i m tring to do this with all things you say into my mind but i cannt get right answer.
plz check my file
& send suggestions to me
Re: check this code <URGENT>
First of all you should set the ScaleMode of the Picture boxes to Pixels so you don't have to loop through a lot of twips and check the same pixel more then once. Secondly use the ScaleWidth and ScaleHeight properties instead of the Height and Width. Thirdly I would wrap this into a more generic function:
VB Code:
Public Function IdenticImages(pic1 As PictureBox, pic2 As PictureBox) As Boolean
Dim x As Long
Dim y As Long
pic1.ScaleMode = vbPixels
pic2.ScaleMode = vbPixels
If pic1.ScaleHeight <> pic2.ScaleHeight Or pic1.ScaleWidth <> pic2.ScaleWidth Then
Exit Function
End If
For y = 0 To pic1.ScaleHeight - 1
For x = 1 To pic1.ScaleWidth - 1
If pic1.Point(x, y) <> pic2.Point(x, y) Then
pic1.PSet (x, y), RGB(255, 0, 0)
Exit Function
End If
Next x
Next y
IdenticImages = True
End Sub
Now you can simply call this function from your code instead.
VB Code:
If IdenticImages(Picture1, Picture2) Then
MsgBox "The pictures are the same!"
c = 1
Else
MsgBox "The images are not the same!"
c = 0
End If
Now, using Point and PSet are very slow so this function will be slow when comparing large images. You could speed it up a little by using the GetPixel API function instead of the Point statement, but it will still be pretty slow on large images.