تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مقال - استخلاص الصور من صورة متحركة gif
#2
في الموضوع أعلاه الكلاس به جزء لم يكتمل وتحديدا في Constructor الخاص بالكلاس ولذلك هذا هو الشكل النهائي للكلاس كالأتي

أيضا من الممكن أن نقوم باستخدام IDisposable Interface مع هذا الكلاس


كود :
Imports System.Drawing.Imaging

Public Class GifImageFrames

#Region " Fields "

Private _frames As Integer
Private _image As Bitmap

#End Region

#Region " Constructor "

Public Sub New()
Me._image = Nothing
Me._frames = 0
End Sub

Public Sub New(ByVal image As Image)
Me._frames = 0
Me._image = image
End Sub

Public Sub New(ByVal frames As Integer, ByVal image As Bitmap)
Me._image = image
Me._frames = frames
End Sub

#End Region

#Region " Properties "

Public ReadOnly Property IsGif As Boolean
Get
If Me._image IsNot Nothing Then
Return Me.IsGifImage(Me._image)
End If
Return Nothing
End Get
End Property

Public ReadOnly Property Image As Bitmap
Get
Return Me._image
End Get
End Property

Public ReadOnly Property Frames As Integer
Get
If Me._image IsNot Nothing Then
Return Me.GetImageFrames(Me._image)
End If
Return 0
End Get
End Property

Public ReadOnly Property Images As List(Of Bitmap)
Get
Return GetImages()
End Get
End Property

#End Region

#Region " Methods "

Private Function GetImageFrames(ByVal img As Image) As Integer
If IsGifImage(img) Then
Dim fDimensions As FrameDimension = New FrameDimension(img.FrameDimensionsList(0))
Dim frames As Integer = img.GetFrameCount(fDimensions)
Return frames
End If
Return 0
End Function

Private Function IsGifImage(ByVal img As Image) As Boolean
If (img Is Nothing) Then
Throw New ArgumentNullException("img")
End If
Dim fDimensions As FrameDimension = New FrameDimension(img.FrameDimensionsList(0))
Dim frames As Integer = img.GetFrameCount(fDimensions)
Dim isGif As Boolean = False
If frames > 1 Then
isGif = True
End If
Return isGif
End Function

Private Function GetImages() As List(Of Bitmap)
If Me._image IsNot Nothing Then
Dim images As New List(Of Bitmap)
Dim gifImage As Image = Me._image
Dim frames As GifImageFrames() = New GifImageFrames() {}
Dim fd As New FrameDimension(gifImage.FrameDimensionsList(0))
Dim frameCount As Integer = gifImage.GetFrameCount(fd)
If frameCount > 1 Then
frames = New GifImageFrames(frameCount - 1) {}
Dim times As Byte() = gifImage.GetPropertyItem(&H5100).Value
For i As Integer = 0 To frameCount - 1
gifImage.SelectActiveFrame(fd, i)
Dim length As Integer = BitConverter.ToInt32(times, 4 * i) * 10
frames(i) = New GifImageFrames(length, New Bitmap(gifImage))
Next
End If

For Each frm As GifImageFrames In frames
images.Add(frm.Image)
Next

Return images
End If
Return Nothing
End Function

#End Region

End Class ' GifImageFrames
}}}
تم الشكر بواسطة:


الردود في هذا الموضوع
مقال - استخلاص الصور من صورة متحركة gif - بواسطة Raggi Tech - 05-10-12, 03:39 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  معلومة :: تعلم كيف تحفظ صورة في My.Settings بدون الإحتياج إلى مسارها! أسامة أحمد 13 7,666 15-04-24, 01:13 AM
آخر رد: أبو جودة
Video [درس فيديو] تقارير الكريستال ريبورت وتغيير مسار الصور أثناء التشغيل رمضان272 0 1,999 28-03-22, 03:18 AM
آخر رد: رمضان272
  شرح خوارزميات معالجة الصور (من دروس الاستاذ فوزي برزنجي) ناديه الشجيري 19 35,530 20-02-22, 02:13 PM
آخر رد: رضوان الجماعي
  التعامل مع الصور Images في بيئة الدوت نت باستخدام +GDI - مقدمة RaggiTech 3 6,341 30-07-21, 05:14 PM
آخر رد: kebboud
  مقال: الكومبو بوكس ComboBox كيف تضيف أيقونات Blue Sky 1 3,452 30-06-19, 10:41 AM
آخر رد: invocker
  Compare Images المقارنة بين الصور Abu Ehab 0 3,642 31-10-18, 04:27 PM
آخر رد: Abu Ehab
  مقدمة إلي ضغط الصور ..... Zip Bitmap silverlight 0 2,598 10-05-18, 04:35 AM
آخر رد: silverlight
  إخفاء تكست في صورة silverlight 0 2,721 02-07-17, 09:31 AM
آخر رد: silverlight
  مشروع لجلب الصور من الماسحة الضوئية (Scanner) m.sami.ak 14 12,914 22-01-17, 10:41 AM
آخر رد: amko
  [VB.NET] تشغيل Twain الخاص بسحب الصور من السكنر في حالة net framework4 ahmed saleh 4 4,780 25-10-15, 07:20 PM
آخر رد: عدنان الشمري

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


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