|
Public Class Form1
Inherits System.Windows.Forms.Form Vom Windows Form Designer generierter Code
Private Function Thumbnail_Proportional(ByVal b As Bitmap, _
ByVal w As Integer, ByVal h As Integer) As Bitmap
If w = 0 And h = 0 Then
w = b.Size.Width
h = b.Size.Height
ElseIf w = 0 Then
w = CInt(h / b.Size.Height * b.Size.Width)
ElseIf h = 0 Then
h = CInt(w / b.Size.Width * b.Size.Height)
End If
Return CType(b.GetThumbnailImage( _
w, h, Nothing, IntPtr.Zero), Bitmap)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim x, y As Integer
Dim sPath As String = Durchsuchen()
If sPath <> String.Empty Then
Dim b As Bitmap = New Bitmap(sPath)
PictureBox1.Image = b
Dim ThumbnailProp As Bitmap = _
Thumbnail_Proportional(b, 50, 0)
PictureBox2.Image = ThumbnailProp
End If
End Sub
Private Function Durchsuchen() As String
Dim OpenFileDialog1 As New OpenFileDialog
With OpenFileDialog1
Dim sb As New System.Text.StringBuilder
With sb
.Append("*.bmp,*.gif,*.jpg,*.png,*.wmf,*.emf,*.ico")
.Append("|*.bmp")
.Append(";*.gif")
.Append(";*.jpg")
.Append(";*.png")
.Append(";*.wmf")
.Append(";*.emf")
.Append(";*.ico")
End With
.Filter = sb.ToString
.FilterIndex = 1
.RestoreDirectory = True
If .ShowDialog() = DialogResult.OK Then
Return .FileName
End If
End With
End Function
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
|
|