I need to check a picturebox for a specific image. I know you can check if the picturebox is populated with an image…
If Not pictureBox.Image is Nothing Then
Else
End If
But in my case, I need to check this picturebox for an image I loaded earlier on in the process.
Here is the current code I’m using to load the image…
PictureBox1.Image = My.Resources.TestImage1
I thought by using the following code I could check the image name, but this apparently does not work.
If PictureBox1.Image = My.Resources.TestImage1 Then
'do something
Else
'do something else
End if
Suggestions?
Image does not have any knowledge of the file name or any other name that it has been loaded from. What you can do, however, is compare images pixel-by-pixel. Try this code:
Credit goes here.
A useful article I found when looking for this answer:
This is how you can check if your images are less than 100% equal, i.e. similar.