|
Public Class Form1
Inherits System.Windows.Forms.Form Vom Windows Form Designer generierter Code
Private _imgl As Image
Private _imgr As Image
Private _links As Boolean = True
Private Puffer() As Byte
Private Sub Form1_Load(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
_imgl = New Bitmap(Me.GetType, "links.JPG")
_imgr = New Bitmap(Me.GetType, "rechts.JPG")
End Sub
#Region "Skalieren"
Private Sub ScaleImageIsotropically(ByVal grfx As Graphics, _
ByVal img As Image, ByVal rect As Rectangle)
Dim szf As New SizeF(img.Width / img.HorizontalResolution, _
img.Height / img.VerticalResolution)
Dim fScale As Single = Math.Min(rect.Width / szf.Width, _
rect.Height / szf.Height)
szf.Width *= fScale
szf.Height *= fScale
grfx.DrawImage(img, rect.X + (rect.Width - szf.Width) / 2, _
rect.Y + (rect.Height - szf.Height) / 2, _
szf.Width, szf.Height)
End Sub
Private Sub Panel1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles Panel1.Paint
If Not _imgl Is Nothing Then
Dim sz As New Size(Panel1.Width, Panel1.Height)
Dim p As New Point(0, 0)
Dim rect As New Rectangle(p, sz)
Dim grfx As Graphics = e.Graphics
ScaleImageIsotropically(grfx, _imgl, rect)
End If
End Sub
Private Sub Panel2_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles Panel2.Paint
If Not _imgr Is Nothing Then
Dim sz As New Size(Panel2.Width, Panel2.Height)
Dim p As New Point(0, 0)
Dim rect As New Rectangle(p, sz)
Dim grfx As Graphics = e.Graphics
ScaleImageIsotropically(grfx, _imgr, rect)
End If
End Sub
#End Region
Private Sub Panel1_Resize(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Panel1.Resize
Panel1.Invalidate()
End Sub
Private Sub Panel2_Resize(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Panel2.Resize
Panel2.Invalidate()
End Sub
End Class
|
|