I used this converter: http://www.dotnetspider.com/convert/Csharp-To-Vb.aspx . It seems to compile the app then use the MSIL to convert it to VB, which is the best way of translation. If this doesn't work, I can manually translate it, so let me know. This is the result:
Dim img1 As Bitmap = New Bitmap("D:\\Documents and Settings\\Sonia\\Desktop\\sonia1.bmp")
Dim img2 As Bitmap = New Bitmap("D:\\Documents and Settings\\Sonia\\Desktop\\sonia2.bmp")
Dim a As Boolean
a= doImagesMatch(img1,img2)
End Sub
Public Function doImagesMatch(ByVal bmp1 As Bitmap, ByVal bmp2 As Bitmap) As Boolean
Try
'each image to a byte array
Dim converter As ImageConverter = New ImageConverter()
'create 2 byte arrays, one for each image
Dim imgBytes1() As Byte = New Byte(1) {}
Dim imgBytes2() As Byte = New Byte(1) {}
'convert images to byte array
imgBytes1 = CType(converter.ConvertTo(bmp1, imgBytes2.GetType()), Byte())
imgBytes2 = CType(converter.ConvertTo(bmp2, imgBytes1.GetType()), Byte())
'now compute a hash for each image from the byte arrays
Dim sha As SHA256Managed = New SHA256Managed()
Dim imgHash1() As Byte = sha.ComputeHash(imgBytes1)
Dim imgHash2() As Byte = sha.ComputeHash(imgBytes2)
'now let's compare the hashes
Dim i As Integer
For i = 0 To imgHash1.Length And i < imgHash2.Length- 1 Step i + 1
If Not (imgHash1(i) = imgHash2(i)) Then
Return False
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
Return False
End Try
Return True Tekmaven
Software Architect
Moderator
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28