LoadAnimImage Problems

BlitzMax Forums/BlitzMax Programming/LoadAnimImage Problems

MacSven(Posted 2010) [#1]
I have built a test programm:

Global bank:TBank=LoadBank("explosion.png")
Global imageframe=LoadAnimImage(bank,64,64,0,20,FILTEREDIMAGE)

Graphics 800,600
While Not KeyHit(KEY_ESCAPE)
	Cls
	SetColor 255,255,255
	DrawImage imageframe,100,100,1
	Flip
Wend
End


you can download the image here:

www.macsven.de/explosion.png

I is a image with 4*5 anim pixelsize 64x64 with transparent background.

What is wrong, my code does not work.


Zeke(Posted 2010) [#2]
wrong sized image. image is only 256x256 pixels (16 frames) but you are trying to load 20 frames.

so resize image to 256x320 pixels and re-arrange frames (Y-position).


MacSven(Posted 2010) [#3]
Thanx!

I do it so.


Reans(Posted 2014) [#4]
I got the same problem. Tries with this my code and getting out of memory access and the buggy end constantly. Take a look at plain blitz code that won't:


Global frame, Global boom_anim, Global time
; Gotta be in graphics mode
Graphics 640,480,16,2
SetBuffer BackBuffer()

camera = CreateCamera()


;MaskImage boom_anim,255,255,255
; Create sprite
sprite = CreateSprite()
; position entity on the screen
PositionEntity sprite, 400,200, 0
EntityTexture sprite,boom_anim, 0

boom_anim=LoadAnimTexture("mage.png",140,128,0,2)

;.SPRITE
time = MilliSecs()
While Not KeyHit(207)
; Timer to animate the image
If MilliSecs() - time > 200 Then
time = MilliSecs()
If frame = 1 Then frame = 0 Else frame = 1 ; advance the frame
EntityTexture sprite, t, frame ; update the entity texture
EndIf

SetBuffer BackBuffer()
RenderWorld()
Flip
Wend
End


GfK(Posted 2014) [#5]
You're trying to apply the texture before you've even loaded it.


Reans(Posted 2014) [#6]
Well, community. Thanks for the reply. I know.
I was trying to write tiny app to make a 3d empty environment
with a textured sprite using loadanimimage and an image with a
row of 5 or 6 images in one strip.
It will exit on 'End'. Any suggestions for this task at me newbee?
Look at the code. I'm looking for an adjustable solution to the
fps update interval between 20 and 500 where it goes for next in
the strip.


Reans(Posted 2014) [#7]
So much for seven minutes...


Brucey(Posted 2014) [#8]
Your example doesn't look like BlitzMax... so you may get more useful replies in the correct forum.


Reans(Posted 2014) [#9]
I know. For those who came in the wrong place (like me), use this anyway, written in Blitz3d and WORKS:

Graphics3D 640, 480,16,2
SetBuffer BackBuffer()
camera = CreateCamera()
light = CreateLight()
RotateEntity light, 90, 0, 0

player = CreateSprite()
PositionEntity player, 0, 0, 5
anim_tex = LoadAnimTexture("264.png", 4, 32, 32, 0, 5)
EntityTexture player, anim_tex, 1

Function AnimSprite(obj, atex, d, f)
frame=MilliSecs()/d Mod f
EntityTexture obj,atex,frame
End Function


While Not KeyHit (207)

AnimSprite (player, anim_tex, 200, 4)

UpdateWorld
RenderWorld
Flip
Wend
End