Drawimage an entire Animimage.

BlitzMax Forums/BlitzMax Beginners Area/Drawimage an entire Animimage.

tonyg(Posted 2006) [#1]
Once loaded via LoadAnimImage what's the easiest way to
draw the entire image?
e.g
Graphics 640 , 480
image:TImage = LoadAnimImage("green_top.png" , 32 , 32 , 0 , 5)
change = 1000
tochange=MilliSecs()+change
While Not KeyHit(KEY_ESCAPE)
	Cls
	DrawImage image , 0 , 0 , <All>
        Flip		
Wend

P.S. I know LoadAnimImage creates individual frames and I am aware of Indie's TAnim. I know I can load as an image then loadanimImage. I know I can loop through each frame drawing it at an offset (but how could I be sure to recreate the original rows/columns?).


Dreamora(Posted 2006) [#2]
There is no way to do this.
You would need to load it through LoadImage and just draw that, because as you already mentioned, the image is broken into subimages with no information where they came from.

An alternative would be the use of "DrawImageRect" functions in the codebase if you wanted to have the power of both sides at the same time.


TomToad(Posted 2006) [#3]
If you know how many rows and columns there are, you could just loop through them. For instance, suppose you broke up a 640x480 image into 32x32 squares. That'd be 20 columns and 15 rows. So:
Local Image:TImage = LoadAnimImage("MyImage.png",32,32,0,20*15)

While Not KeyHit(KEY_ESCAPE)
For Local Y = 0 To 14
 For Local X = 0 To 19
  Local Cell = Y*20+X
  DrawImage X*32,Y*32,Cell
 Next
Next
Wend