It turns out a little more complicated than I thought. I created a simple image comparison function. I made a demo by adding a regular Button to the form and making it switch between 2 images. This is the code:
Private Sub Button1_Click_2(sender As Object, e As EventArgs) Handles Button1.Click
If CompareImages(Button1.BackgroundImage, My.Resources.AdvancedHMILogoBR) Then
Button1.BackgroundImage = My.Resources.RoundMeterNeedle
Else
Button1.BackgroundImage = My.Resources.AdvancedHMILogoBR
End If
End Sub
Private Function CompareImages(ByRef Image1 As Bitmap, ByRef image2 As Bitmap) As Boolean
If Image1 Is Nothing AndAlso image2 IsNot Nothing Then
Return False
End If
If image2 Is Nothing AndAlso Image1 IsNot Nothing Then
Return False
End If
If Image1.Size.Width = image2.Size.Width AndAlso Image1.Size.Height = image2.Size.Height Then
If Image1.GetPixel(0, 0).A = image2.GetPixel(0, 0).A And Image1.GetPixel(0, 0).R = image2.GetPixel(0, 0).R And
Image1.GetPixel(0, 0).G = image2.GetPixel(0, 0).G And Image1.GetPixel(0, 0).B = image2.GetPixel(0, 0).B Then
Return True
Else
Return False
End If
Else
Return False
End If
End Function