Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

need help with PixelMatch Function

can someone please fix this function?

Private Function PixelMatches(?,?) As Boolean
Dim y As Integer
Match = False
For y = 0 To 10
If PixelColor1(y) <> PixelColor2(y) Then
Exit Function
End If
Next
PixelMatches = True
End Function
[322 byte] By [stupiddude] at [2007-11-11 10:05:23]
# 1 Re: need help with PixelMatch Function
Try this:Private Function PixelMatches(PixelColor1() As Long, PixelColor2() As Long) As Boolean
Dim y As Integer
For y = LBound(PixelColor1) To UBound(PixelColor1)
If PixelColor1(y) = PixelColor2(y) Then
PixelMatches = True
Exit Function
End If
Next y
PixelMatches = False
End Function
Ron Weller at 2007-11-11 17:23:10 >
# 2 Re: need help with PixelMatch Function
Ron's function is correct but I think in his original function he want to check if all pixels matches not one of them matches only ..

so u have to remove the line pixelMAtches = true and at the end of the code make pixelmatches = true .

the if statment will be :
If PixelColor1(y) <> PixelColor2(y) Then Exit Function
only .
by the way , u must pass to the function array of pixels that contains all the pixels in the first array and all other pixels to compare with them in the other array .
Amahdy at 2007-11-11 17:24:18 >
# 3 Re: need help with PixelMatch Function
Actually if you look at his original code, every color in the first array must match every corrisponding color in the second array or it terminated with a false match. So the big question should have been, What are you trying to do? You can't tell if he is trying to find the first matching color, any matching color, or all must match? Based on the code all must match but then he would not have needed it fixed if that is what he was looking for. The version I gave only looks for the first element in the first array that matches the same element in the second array; but that may not be correct either, so???
Ron Weller at 2007-11-11 17:25:16 >