Prova così!
Metti 2 textbox e chiamale txtFile1 e txtFile2, poi metti una pictureBox e chiamala picResult.
Infine metti un bottone al cui click assegni questo codice:
Questo non fa altro che caricare le immagini corrispondenti ai percorsi che inserirai nelle 2 textbox (es: "C:\miaCartella\miaIMG.jpg") e pixel per pixel controllare se ci sono differenze!codice:Me.Cursor = Cursors.WaitCursor Application.DoEvents() ' Load the images. Dim bm1 As Bitmap = Image.FromFile(txtFile1.Text) Dim bm2 As Bitmap = Image.FromFile(txtFile2.Text) ' Make a difference image. Dim wid As Integer = Math.Min(bm1.Width, bm2.Width) Dim hgt As Integer = Math.Min(bm1.Height, bm2.Height) Dim bm3 As New Bitmap(wid, hgt) ' Create the difference image. Dim are_identical As Boolean = True Dim r1, g1, b1, r2, g2, b2, r3, g3, b3 As Integer Dim eq_color As Color = Color.White Dim ne_color As Color = Color.Red For x As Integer = 0 To wid - 1 For y As Integer = 0 To hgt - 1 If bm1.GetPixel(x, y).Equals(bm2.GetPixel(x, _ y)) Then bm3.SetPixel(x, y, eq_color) Else bm3.SetPixel(x, y, ne_color) are_identical = False End If Next y Next x ' Display the result. picResult.Image = bm3 Me.Cursor = Cursors.Default If (bm1.Width <> bm2.Width) OrElse (bm1.Height <> _ bm2.Height) Then are_identical = False If are_identical Then MessageBox.Show("Le immagini sono identiche!") Else MessageBox.Show("Le immagini sono diverse!") End If bm1.Dispose() bm2.Dispose()
Alla fine nella pictureBox assegnerà il colore (rosso se son diverse ecc)
Questa è la base son sicura che smanettandoci un po arriverai ad adattarlo a ciò che ti serve!
Ciao!![]()

Rispondi quotando