来源:http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=180291
Dim animatedGif As New Bitmap("c:\216371.gif")
' A Gif image's frame delays are contained in a byte array GDI显示动态GIF代码(VB.NET)
' in the image's PropertyTagFrameDelay Property Item's
' value property.
' Retrieve the byte array...
Dim PropertyTagFrameDelay As Integer = &H5100
Dim propItem As Imaging.PropertyItem = animatedGif.GetPropertyItem(PropertyTagFrameDelay)
Dim bytes() As Byte = propItem.Value
' Get the frame count for the Gif...
Dim frameDimension As New Imaging.FrameDimension(animatedGif.FrameDimensionsList(0))
Dim frameCount As Integer = animatedGif.GetFrameCount(frameDimension.Time)
' Create an array of integers to contain the delays,
' in hundredths of a second, between each frame in the Gif image.
Dim delays(frameCount) As Integer
Dim i As IntegerGDI显示动态GIF代码(VB.NET)
For i = 0 To frameCount - 1
delays(i) = BitConverter.ToInt32(bytes, i * 4)
Next
' Play the Gif one time...
For i = 0 To animatedGif.GetFrameCount(frameDimension) - 1
animatedGif.SelectActiveFrame(frameDimension, i)
Dim memoryStream As New System.IO.MemoryStream
animatedGif.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Bmp)
PictureBox1.Image = System.Drawing.Image.FromStream(memoryStream)
Application.DoEvents()
Threading.Thread.CurrentThread.Sleep(delays(i) * 10)
Next
GDI显示动态GIF代码(VB.NET)