Usuário com melhor resposta
VB2010: Bitmap: como obter o tempo entre as frames do gif?

Pergunta
-
Respostas
-
Olá,
No exemplo abaixo você consegue obter o tempo da frame em "Dim length As Integer"
Private Class Frame Public Property MilliSecondDuration As Integer Public Property Bitmap As Image Public Sub New(ByVal duration As Integer, ByVal img As Bitmap) Me.MilliSecondDuration = duration Me.Bitmap = img End Sub End Class Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim gif As Image = Image.FromFile("imagem.gif") Dim fd As New Imaging.FrameDimension(gif.FrameDimensionsList()(0)) Dim frameCount As Integer = gif.GetFrameCount(fd) Dim frames(frameCount) As Frame If frameCount > 1 Then Dim times() As Byte = gif.GetPropertyItem(&H5100).Value For i As Integer = 0 To frameCount - 1 gif.SelectActiveFrame(fd, i) Dim length As Integer = BitConverter.ToInt32(times, 4 * i) * 10 frames(i) = New Frame(length, New Bitmap(gif)) Next End If End Sub
Att,
Danilo Peres
- Marcado como Resposta Cambalinho terça-feira, 24 de janeiro de 2017 21:52
Todas as Respostas
-
Olá,
No exemplo abaixo você consegue obter o tempo da frame em "Dim length As Integer"
Private Class Frame Public Property MilliSecondDuration As Integer Public Property Bitmap As Image Public Sub New(ByVal duration As Integer, ByVal img As Bitmap) Me.MilliSecondDuration = duration Me.Bitmap = img End Sub End Class Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim gif As Image = Image.FromFile("imagem.gif") Dim fd As New Imaging.FrameDimension(gif.FrameDimensionsList()(0)) Dim frameCount As Integer = gif.GetFrameCount(fd) Dim frames(frameCount) As Frame If frameCount > 1 Then Dim times() As Byte = gif.GetPropertyItem(&H5100).Value For i As Integer = 0 To frameCount - 1 gif.SelectActiveFrame(fd, i) Dim length As Integer = BitConverter.ToInt32(times, 4 * i) * 10 frames(i) = New Frame(length, New Bitmap(gif)) Next End If End Sub
Att,
Danilo Peres
- Marcado como Resposta Cambalinho terça-feira, 24 de janeiro de 2017 21:52
-