Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        '显示按钮
        Dim file_name As String = ""          '存放选取的文件名
        Dim file As New OpenFileDialog()     '创建OpenFileDialog类的实例
        file.Filter = "*.jpg;*.bmp|*.jpg;*.bmp|所有文件(*.*)|*.*"
        If file.ShowDialog() = DialogResult.OK Then
            file_name = file.FileName
            Dim bitmap As New Bitmap(file_name)
            Dim g As Graphics = Me.CreateGraphics()
            '原图大小显示 
            g.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height)
            '缩半显示 
            g.DrawImage(bitmap, 200, 0, bitmap.Width \ 2, bitmap.Height \ 2)
            bitmap.Dispose()            '释放占用的资源 
            g.Dispose()
        End If
    End Sub

End Class
