تقييم الموضوع :
  • 1 أصوات - بمعدل 5
  • 1
  • 2
  • 3
  • 4
  • 5
[مقال] Check the file format of an Image
#2
-
في الزيادة إفادة.....

منقول

دالة GetImageFormat لتحديد نوع الصورة ( BMP, GIF, JPEG, PNG, TIFF, ICON, GIF animation )
كود :
' دالة تحديد نوع الصورة  ( BMP, GIF, JPEG, PNG, TIFF, ICON, GIF animation )
Private Function GetImageFormat(ByVal img As Image) As String
    Dim imgFormat As String = "Unknown"
    If img.RawFormat.Guid = Imaging.ImageFormat.Bmp.Guid Then imgFormat = "BMP"
    If img.RawFormat.Guid = Imaging.ImageFormat.Gif.Guid Then imgFormat = "GIF"
    If img.RawFormat.Guid = Imaging.ImageFormat.Jpeg.Guid Then imgFormat = "JPEG"
    If img.RawFormat.Guid = Imaging.ImageFormat.Png.Guid Then imgFormat = "PNG"
    If img.RawFormat.Guid = Imaging.ImageFormat.Tiff.Guid Then imgFormat = "TIFF"
    If img.RawFormat.Guid = Imaging.ImageFormat.Icon.Guid Then imgFormat = "ICON"
    If imgFormat = "GIF" AndAlso img.GetFrameCount(Imaging.FrameDimension.Time) > 1 Then imgFormat = "GIF animation"
    Return imgFormat
End Function

طريقة استخدامها
كود :
' (صورة من ملف (حتى لو تم تغيير النوع من اسم الملف
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    Using op As New OpenFileDialog()
        op.Filter = "Images (*.bmp,*.gif,*.jpg,*.png,*.tif,*.ico)|*.bmp;*.gif;*.jpg;*.png;*.tif;*.ico"
        If op.ShowDialog = DialogResult.OK Then
            MsgBox(GetImageFormat(Image.FromFile(op.FileName)))
        End If
    End Using
End Sub
كود :
' صورة من الريسورس
Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
    MsgBox(GetImageFormat(My.Resources.logo))
End Sub
الرد }}}
تم الشكر بواسطة: سعود , الشاكي لله , Japan


الردود في هذا الموضوع
Check the file format of an Image - بواسطة silverlight - 15-05-14, 04:51 AM
RE: Check the file format of an Image - بواسطة vbnet - 15-05-14, 09:47 AM
RE: Check the file format of an Image - بواسطة silverlight - 15-05-14, 04:48 PM
RE: Check the file format of an Image - بواسطة Sajad - 28-05-14, 05:02 PM


التنقل السريع :


يقوم بقرائة الموضوع: