|
Imports System.Drawing.Imaging
Public Class Form1
Inherits System.Windows.Forms.Form Vom Windows Form Designer generierter Code
Private objBitmap As Bitmap
Private objGraphics As Graphics
Private strImgFile As String = "c:\test.png"
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
objBitmap = New Bitmap(100, 100, PixelFormat.Format32bppArgb)
objGraphics = Graphics.FromImage(objBitmap)
Dim img As Image = Image.FromFile("../yukon.gif")
objGraphics.DrawImage(img, 0, 0)
Dim rect1 As New Rectangle(10, 10, 50, 50)
objGraphics.DrawEllipse(New Pen(Color.Red), rect1)
Dim point1 As New Point(50, 65)
Dim point2 As New Point(70, 25)
Dim point3 As New Point(10, 5)
Dim trianglePoints As Point() = {point1, point2, point3}
objGraphics.DrawPolygon(New Pen(Color.DarkSeaGreen), _
trianglePoints)
PictureBox1.Image = objBitmap
objGraphics.Dispose()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
If MessageBox.Show("Bild speichern als " & strImgFile & " ?", _
"Bild speichern?", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question) = DialogResult.Yes Then
objBitmap.Save(strImgFile, ImageFormat.Png)
MessageBox.Show("Bild wurde gespeichert als " & strImgFile, _
"Bild wurde gespeichert", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
If MessageBox.Show( _
"Bilddatei mit dem Standardprogramm öffnen?", _
"Bilddatei öffnen?", MessageBoxButtons.YesNo, _
MessageBoxIcon.Question) = DialogResult.Yes Then
Dim p As Process = Process.Start("c:\test.png")
End If
objBitmap.Dispose()
End If
End Sub
End Class
|
|