Loading images into arrays

BlitzMax Forums/BlitzMax Beginners Area/Loading images into arrays

*(Posted 2005) [#1]
What im trying to do is load an animated image (Animimage) into an array segment, using the following code:
strict

graphics 640,480,16

IncBin "Data\Apple.PNG"

Global Array[10]

Array[0] = LoadAnimImage( "incbin::Data\Apple.PNG", 32, 32, 0, 7 )

DrawImage Array[0], rnd( 640 ), rnd( 480 ), 0
flip
Repeat;until keydown(KEY_ESCAPE)=1
end


The thing is at the Drawimage it keeps chucking up a error something about Null images and when I look the image isnt loaded into the array. Can images only be loaded into variables now or is there something im not doing right?


Damien Sturdy(Posted 2005) [#2]
images arent stored by Index anymore- theyre loaded as an object...
I've not used max or a while but something like

Global Array:TImage[10] should make it work.
....Hey...

Heh.... I'm kind of a newbie too, Shouldn't that code work at default?


tonyg(Posted 2005) [#3]
This works OK...
Strict

Graphics 640,480,16

Incbin "max.PNG"

Global Array[10]
Local frame:Int
Array[0] = LoadAnimImage( "incbin::max.PNG", 32, 256, 0, 7 )
While Not KeyHit(key_escape)
    Cls
	DrawImage Array[0], 0,0, frame
	DrawText frame,0,300
	frame:+1
	If frame=7 frame=0
	Flip 
	FlushMem
wend
End



Damien Sturdy(Posted 2005) [#4]
*Pastes*
i *think* you need the Ramstream module for IncBin to work :) Im not at my puter so i cant give you the correct full name.
Maybe "BRL.RamStream"


----
I see you havent done any module stuff, so i dont know if this is your problem :)


Damien Sturdy(Posted 2005) [#5]
*Pastes*
i *think* you need the Ramstream module for IncBin to work :) Im not at my puter so i cant give you the correct full name.
Maybe "BRL.RamStream"


----
I see you havent done any module stuff, so i dont know if this is your problem :)


Perturbatio(Posted 2005) [#6]
i *think* you need the Ramstream module for IncBin to work :) Im not at my puter so i cant give you the correct full name.


He doesn't need to include it since he isn't using framework.


Damien Sturdy(Posted 2005) [#7]
*Blows Raspberry at Pert*


Perturbatio(Posted 2005) [#8]
}:þ


Oddball(Posted 2005) [#9]
Someone posted in a different thread that you need to use forward slashes '/' with incbin. Not tested it though.


FlameDuck(Posted 2005) [#10]
Someone posted in a different thread that you need to use forward slashes '/' with incbin. Not tested it though.
You should just always use forward slashes regardless.

Backwards slashes was a stupid idea, and just goes to show how unimaginative and clumsy Gates and Allen where, when trying to be innovative. I can just imageine the scene now;

Gates: We need to do have some way of accessing resources so it doesn't look like we riped off Ritchie and Thompson.
Allen: I know, we'll use drive letters, instead of a virtual filesystem!
Gates: Good idea. Except Kildall already had that one.
Allen: No worries, we'll just use awkward backwards slashes, so accessing directories is a right pain.
Gates: Awesome idea, we wouldn't want people to actually enjoy using this. That way we can control job security for ourselves and future employees and fanboys.

It was a dumb idea then, and remains so to this day. Somewhere along the line (probably after the death of CP/M) MS-DOS would suddenly accept forward slashes as a valid directory delimiter. And there was much rejoicing!


*(Posted 2005) [#11]
yeah the wiki mentions forward slashes and the TImage thing works. Pitty the official docs that come with BlitzMax dont.


Rimmsy(Posted 2005) [#12]
edz, a good tip is if you're going to use images like this
local i=loadimage()

you have to release them like so:
release i

If you declare them as :TImage, flushmem will automagically get rid of them for you if they have a 0 reference count. At least this is what the docs say, but I didn't read it until way through my project.


*(Posted 2005) [#13]
im declaring as TImage atm as this is good for arrays :D


Rimmsy(Posted 2005) [#14]
it's all good, baby