I am coding using Visual Basic. I have a little problem however.
For my program, I need to layer GIFs/PNGs. I have accomplished this by using .DrawImage()
It works fine however, the GIFs are inanimate and static.
I have tried using the ImageAnimator Class, however, I am a bit in the dark. I tried using the sample code from MSDN, and it is not working for me. This is probably because I don't quite understand it.
Private animatedImage As New Bitmap(My.Resources._a_takingnotes)
Private currentlyAnimating As Boolean = False
Public Sub AnimateImage()
If Not currentlyAnimating Then
'Begin the animation only once.
ImageAnimator.Animate(animatedImage, _
New EventHandler(AddressOf Me.OnFrameChanged))
currentlyAnimating = True
End If
End Sub
Private Sub OnFrameChanged(ByVal o As Object, ByVal e As EventArgs)
'Force a call to the Paint event handler.
Me.Invalidate()
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
'Begin the animation.
AnimateImage()
'Get the next frame ready for rendering.
ImageAnimator.UpdateFrames()
'Draw the next frame in the animation.
e.Graphics.DrawImage(Me.animatedImage, New Point(0, 0))
PictureBox2.Image = Nothing
PictureBox2.Image = animatedImage
End Sub
The above is the code that is supposed to animate the "(a)takingnotes.gif" (called as a resource).
It returns a static image of the first frame in the PictureBox.
Thank you!
EDIT: AnimateImage()
is called on Load, which didn't work. I also tested on every Timer Tick, which also didn't work.