erstmal danke für die hilfe
ich versuche gerade den quelltext zu verstehen und zu verwenden....ich lade mir 2 bilder in meine pictureboxen und versuche per button die bilder zu vergleichen. jedoch bekomm ich als resultat nur ein error und ein warnungsschild in der linken oberen ecke angezeigt.
der qc dazu
Public Class Form1
Dim bm1, bm2 As New Bitmap(100, 100)
Dim g As Graphics = Graphics.FromImage(bm1)
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button3.Click
g.Clear(Color.White)
For i As Int32 = 0 To bm1.Height - 1 Step 2
g.DrawLine(Pens.Blue, 0, i, bm1.Width, i)
Next
bm2 = CType(bm1.Clone, Bitmap)
g.DrawImage(SystemIcons.Error.ToBitmap, 10, 10)
g.DrawImage(SystemIcons.Warning.ToBitmap, 50, 50)
PictureBox1.SetBounds(5, 5, 100, 100)
PictureBox2.SetBounds(110, 5, 100, 100)
PictureBox3.SetBounds(215, 5, 100, 100)
PictureBox1.Image = bm1
PictureBox2.Image = bm2
PictureBox3.Image = BitmapDiff(bm1, bm2)
End Sub
Private Function BitmapDiff(ByVal b1 As Bitmap, ByVal b2 As Bitmap) As Bitmap
Dim bm As New Bitmap(b1.Width, b1.Height)
For y As Integer = 0 To b1.Height - 1
For x As Integer = 0 To b1.Width - 1
If b1.GetPixel(x, y) <> b2.GetPixel(x, y) Then
bm.SetPixel(x, y, b1.GetPixel(x, y))
End If
Next
Next
Return bm
End Function
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Me.PictureBox1.BackgroundImageLayout = _
System.Windows.Forms.ImageLayout.None
Me.PictureBox1.Load(ComboBox1.SelectedItem)
Me.PictureBox1.Refresh()
bm1 = Me.PictureBox1.Image
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
Me.PictureBox2.BackgroundImageLayout = _
System.Windows.Forms.ImageLayout.None
Me.PictureBox2.Load(ComboBox2.SelectedItem)
Me.PictureBox2.Refresh()
bm2 = Me.PictureBox2.Image
End Sub
End Class |