GIF manipulation at vb.net
Is it possible, without creating an external library of codes, to separate the .gif file into its own separate frames and, conversely, collect a group of images into one?
I've spent some time in the System.Drawing namespace and can't figure out how to do this.
Also, I can't figure out what to pass as a parameter for GetFrameCount. I don't know what they mean by "dimension" and apparently it cannot be left null.
Also, is it possible to have playback control over a gif without first splitting it and recompiling / displaying it in a way that simulates playback?
Thanks for the help.
It's at vb.net, 2008.
EDIT: If this is not possible without an external library, which one is the best to use?
source to share
I used code similar to this and it worked great ... I didn't invent it, so credit for the person who did (I forgot) ... (maybe here ).
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 Function SeparateGif() As Frame()
Dim gif As Image = Image.FromFile("MyGif.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
Return frames
End Function
source to share
According to this forum post, saving animated GIFs is not supported in .NET. So no, without an external code library, it's probably not possible.
Any specific reason why you are not accessing external libs?
source to share