Adding animation frames

BlitzMax Forums/BlitzMax Programming/Adding animation frames

How would I go about adding frames to an existing animation? For example, suppose I had an animated TImage:
Local Animation:TImage = LoadAnimImage("MyAnim.png",64,64,0,8)
'8 frame animation

And I wanted to add another TImage as an aditional frame to the animation:
Local NewFrame:TImage = LoadImage("NewFrame.png")
'Now I want to add NewFrame to Animation as 9th frame


Not extensively tested so feedback welcome
Graphics 800 , 600
Local image1:timage = LoadAnimImage("add_anim_test.png" , 32 , 32 , 0 , 2)
Local image2:timage = LoadImage("max.png")
For Local x1:Int = 0 To Len(image1.frames) - 1
	DrawImage image1 , x1 * 32 , 0 , x1
Next
Flip
WaitKey()
add_animframe(image1,image2)
For Local x2:Int = 0 To Len(image1.frames) - 1
	DrawImage image1 , x2 * 32 , 100 , x2
Next
Flip
WaitKey()

Function add_animframe(image1:timage , image2:timage)
	If ImageWidth(image1) <> ImageWidth(image2) Or ImageHeight(image1) <> ImageHeight(image2)
		Notify "Images are different sizes"
	Else
		' Create our pixmap from the image
 		Local temp_pixmap:tpixmap = LockImage(image2)
		' slice our frame counters to cater for the extra image
		image1.frames = image1.frames[..Len(image1.frames) + 1]
		image1.pixmaps = image1.pixmaps[..Len(image1.pixmaps) + 1]
		image1.seqs = image1.seqs[..Len(image1.seqs) + 1]
		' include our new pixmap in the existing array of pixmaps
		image1.setpixmap(Len(image1.pixmaps) - 1 , temp_pixmap)
		'create a frawe from the pixmap
		image1.frame(Len(image1.frames) - 1)
	EndIf
End Function



Thanks tonyg. I think that's exactly what I'm looking for. I assume this is cross-platform as well.

It's standard Bmx code so should be.