Hallo,
ich möchte von Bild- bzw. Video-Datei Thumbnails erstellen. (werden als Bilddateien zur späteren Verwendung im Programm gespeichert)
Das funktioniert mit Bildateien.
Bei Videodateien ist das Thumbnail extrem klein! Wie kann ich das ändern???
Verweis auf 'ThumbnailGenerator.dll'
' PictureBox [pb1] W/H: 178/101 - BorderStyle = FixedSingle
' ImageList1.Images.Item(0) W/H: 176/99 - Hintergrund
' ImageList2.Images.Item(0) W/H: 40/40 - Videosymbol
Imports System.IO ' File.exists(), Path.GetExtension()
Public Class frmMain
Private Sub Button1_Click(...) Handles Button1.Click
'*****************************************************************************
Me.pb1.Image = getThumbnail("C:\...\Video.MOV") ' Bild-W/H: 2816/1584
'Me.pb1.Image = getThumbnail("C:\...\IMG_1517.JPG") ' 2816 x 1584 Pixel
'Me.pb1.Image = getThumbnail("C:\...\Bild1.JPG") ' 772 x 666 Pixel
'Me.pb1.Image = getThumbnail("C:\...\Bild2.JPG") ' 770 x 260 Pixel
'Me.pb1.Image = getThumbnail("C:\...\Bild3.JPG") ' 320 x 668 Pixel
End Sub
Private Function getThumbnail(ByVal strPathFile As String) As Bitmap
'*****************************************************************************
Dim bolIsVideo As Boolean = False
If File.Exists(strPathFile) Then
Dim dbRel, dbRelH, dbDelW As Double
Dim strExt As String = Path.GetExtension(strPathFile).ToLower
Dim bmFile As Bitmap = Nothing
Dim bmThumb As New Bitmap(Me.ImageList1.Images.Item(0))
Dim g As Graphics = Graphics.FromImage(bmThumb)
Select Case strExt
Case".jpg",".jpeg", ".bmp", ".gif"
bmFile = DirectCast(Bitmap.FromFile(strPathFile), Bitmap)
Case ".wmv", ".avi", ".mov"
bolIsVideo = True
Dim shellIcon As New ShellThumbnail.ShellThumbnail
bmFile = shellIcon.GetThumbnail(strPathFile)
If bmFile Is Nothing Then bmFile = bmThumb
Case Else
MsgBox("Datei '" & strPathFile & "' wurde nicht gefunden bzw. ... ", _
MsgBoxStyle.Information, "Fehler")
Return Nothing
End Select
Dim W As Integer = bmFile.Width
Dim H As Integer = bmFile.Height
dbDelW = W/176
dbRelH = H/99
If dbDelW > 1 Or dbRelH > 1 Then
If dbDelW > dbRelH Then
dbRel = dbDelW
Else
dbRel = dbRelH
End If
W = CInt(W/dbRel)
H = CInt(H/dbRel)
End If
Dim X As Integer = CInt((176-W)/2)
Dim Y As Integer = CInt((99-H)/2)
g.DrawImage(bmFile, New Rectangle(X,Y,W,H))
If bolIsVideo = True Then
Dim imgVideo As Image = Me.ImageList2.Images.Item(0)
Dim recImgVideo As New Rectangle(CInt((176-imgVideo.Width)/2), _
CInt((99-imgVideo.Height)/2), imgVideo.Width, imgVideo.Height)
Dim Path As New Drawing2D.GraphicsPath()
Path.AddEllipse(recImgVideo)
g.SetClip(Path)
g.DrawImage(imgVideo, recImgVideo.Left, recImgVideo.Top)
imgVideo.Dispose()
End If
g.Dispose()
bmFile.Dispose()
Return bmThumb
Else
MsgBox("Datei nicht gefunden", MsgBoxStyle.Information, "Fehler")
Return Nothing
End If
End Function
End Class |