Images into Array

BlitzMax Forums/BlitzMax Programming/Images into Array

Xerra(Posted 2015) [#1]
I've not tried to load images into an array before but wanted to do so for a project I was working on yesterday.


SuperStrict
Global Images:Timage[2,2]
Images[0,0] = loadimage "gfx\image1.png"
Images[0,1] = loadimage "gfx\image2.png"
images[1,0] = loadimage "gfx\image3.png"
Images[1,1] = Loadimage "gfx\image4.png"
' etc


I've punched that in from memory as I'm on work computer and code is at home but surely this should work? When I run it it will say I'm trying to load an integer into the wrong variable type, or words to that effect.


skidracer(Posted 2015) [#2]
You need brackets after loadimage otherwise BlitzMax thinks you want to store a pointer to the function in the array and not the result of calling the function.


Xerra(Posted 2015) [#3]
Aha, enlightenment...

Images[0,0] = loadimage() "gfx\image1.png"


or

Images[0,0] = loadimage[] "gfx\image1.png"


is the correct syntax?


Brucey(Posted 2015) [#4]
Seriously? LoadImage is a function call :
Images[0,0] = loadimage("gfx\image1.png")



Derron(Posted 2015) [#5]
No ... LoadImage(param) -> LoadImage("gfx/image1.png")

Please pay attention to the "/" instead of "\" - only windows uses the backslash, but accepts the "/"-slash variant too (which is needed for linux/mac).


bye
Ron


Xerra(Posted 2015) [#6]
Sorry, Brucey. Was just typing from memory (not that great) and got the syntax wrong. We're not all experts at this, you know?

And I didn't know about the "/" "\" path restriction for Macs/Linux so thanks for that, Derron. I always wondered why both seemed to work when I tried it. Thanks for that.


Brucey(Posted 2015) [#7]
Sorry, it's just that you've been using function calls with brackets in most of your other posts, I assumed you must have had a brain fart or something ;-)