Private bgImage As Image = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
bgImage = Me.BackgroundImage
StretchBackground()
End Sub
Private Sub Form1_Resize(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Resize
If Not Me.WindowState = FormWindowState.Minimized Then
StretchBackground()
End If
End Sub
Private Sub StretchBackground()
If Not bgImage Is Nothing Then
Me.BackgroundImage = ResizeImage(bgImage, _
Me.ClientSize.Width, _
Me.ClientSize.Height)
End If
End Sub
Private Function ResizeImage(ByVal img As Image, _
ByVal width As Integer, _
ByVal height As Integer) As Bitmap
Dim bm As New Bitmap(width, height)
Dim g As Graphics = Graphics.FromImage(bm)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(img, 0, 0, width, height)
Return bm
End Function