Animated Images 101

BlitzMax Forums/BlitzMax Tutorials/Animated Images 101

ninjarat(Posted 2007) [#1]
So you want to load an image strip? Well, BlitzMax has you covered for that, but if you want to load a strip of images, and then get the Pixmaps, you'll need to know how the TImage Class works. First use this to load the strip:

Local myanimation:TImage=LoadAnimImage(myurl:Object,width,height,first,count,flags=-1)


Now you must extract the pixmaps. You'll need to access the pixmap field of the TImage Class on the instance 'myanimation' you created previously. This is the BRL code used to define a TImage (DO NOT INCORPORATE IN TO YOUR OWN CODE, IT'S AUTOMATICALLY DONE FOR YOU):



As you can see, one of the field vars is 'pixmaps', a TPixmap Array. You'll need to get these manually. Ahem, Mark, ahem, Simon, there needs to be a BRL function for returning that. Or maybe not. Your program will look something like this now:

Local myanimation:TImage=LoadAnimImage(myurl:Object,width,height,first,count,flags=-1)
Local pixmaps:TPixmap[]=myanimation.pixmaps


There! Pixmaps loaded! All you have to do now, is do whatever you want with the resulting pixmaps. You can additionally turn each one in to a TImage for all the special rendering features that are provided with it. Like this:

Local myanimation:TImage=LoadAnimImage(myurl:Object,width,height,first,count,flags=-1)
Local pixmaps:TPixmap[]=myanimation.pixmaps
Local images:TImage[pixmaps.length]

For j=0 to pixmaps.length-1
	images[j]=LoadImage(pixmaps[j])
Next


Hope this helps!


tonyg(Posted 2007) [#2]
I think I'm missing something.
What would we use this for?
Currently, if I want access to an image frame's pixmap I use lockimage with the frame parm.