Cant Load File with "_" in it?

BlitzMax Forums/BlitzMax Beginners Area/Cant Load File with "_" in it?

Moogles(Posted 2006) [#1]
I think i heard that in blitzmax you have to use / instead of \ because of some reason. and that you cant have a space in file paths or something. is this another one? because when i load an image called some_thing.png blitzmax loads it as null even though its there? is this a bug or is this how its meant to be? and is there a post talking about these stuffs or "limits" as i call them. thanks.


tonyg(Posted 2006) [#2]
I can load "some_thing.png", "some thing.png", c:\some thing.png", "c:/some thing.png" and "c:/program files/some thing.png" without a problem in 1.18.
Where did you hear about these restrictions?
I remember there was an issue with a space in the Blitzmax install path (e.g. couldn't use Program Files) but this was fixed a few releases ago.


Moogles(Posted 2006) [#3]
yea i know. im still using 1.16 because of indiepaths software render post. it doesnt work with version 1.18 :/
i remember the space in a path thing and i thought there was more. it seems in 1.16 you cant load with a _ in the filename or path. :/
ill update to 1.18 and i guess ill try and see why it wont let me compile when i use indiepaths method.


Dreamora(Posted 2006) [#4]
If you want to load stuff with " " in it, you have to modify the path to the following

chr(32)+path$+chr(32) (on windows at least)
Thats the same convention is windows uses itselfs for links etc


Moogles(Posted 2006) [#5]
its not the " " its the "_" but ill update to 1.18 and see why the heck wont it compile if i set the render mode as TnL


tonyg(Posted 2006) [#6]
I'm sure I used "_" in my image names in 1.16 as well.


Moogles(Posted 2006) [#7]
hmm well its still not working for me in 1.18 :/
maybe coz im using Max Community IDE?


Floyd(Posted 2006) [#8]
If you suspect the file name is the problem then rename the file.


tonyg(Posted 2006) [#9]
Have you tried multiple images, image formats etc.
Does the same image work renamed?
Simple as it might be, post your code.


Moogles(Posted 2006) [#10]
sure heres my code.
Graphics 640,480
Global bomber=LoadAnimImage("gfx/players/bomberman/walk_down.png",14,24,1,10,FILTEREDIMAGE|MIPMAPPEDIMAGE)
Print bomber

if i change walk_down to waiting it works. also how do i make an animation? i did it before but now i get errors. i got the frame height and width right but if it has 10 frames to display which numbers do i put as 1st grame ans frame count?
thanks


Dreamora(Posted 2006) [#11]
Frames are 0 to 9 (following regular array conventions, not the broken b3d ones)

btw: Did you try it with the chr(32)+ ... + chr(32) to check if it makes a difference?


Moogles(Posted 2006) [#12]
k ill try the frames. will 1 to 10 work also?
chr(32) is a space right? whats the number for _
thats the one i need.

[edit] OHOH its the 0 - 9 that makes it work. why cant i use 1 - 10?


Dreamora(Posted 2006) [#13]
No, chr(32) is the Ascii for " which is needed for non alphanumeric paths on windows. thus chr(32) + path$ + chr(32) (if there is an escape character for " you can use this as well, but I'm not aware of one)

You can't use 1-10 because BM arrays follow the C array rules (which internally are that way because of pointers). An array with 10 entries has indices 0 - 9.

If you want use 1 - 10 just do a -1 in the DrawImage call and not on the variable you use to set the actual frame :-)
That way it would be more natural to you but still ok for bm
=> FrameNr - 1 instead of FrameNr on the DrawImage call


tonyg(Posted 2006) [#14]
I can load an animimage with a "_" in the name without a problem either using an integer or TImage handle.
You *will* get a problem if you try to load too many frames.
The cell_count is that. Not the number of frames in the file but the number of frames you want to load.
If you specify first_cell as '1' and you have 10 frames then the max you can load is 9.


Moogles(Posted 2006) [#15]
the "_" problem was actually the amount of frames. so i see. bmax uses zero based arrays. i didnt know :/ im fixing my code now. i wanted to use 1 - 10 because i thought it would be logical. and i wanted it to be easier to put inside my types. i guess ill keep it simple and use 0 - 9 instead of 1 - 10 and then wonder why later on i use DrawImage(image,x,y,frame-1) :S

Thanks! ^_-


undomiel(Posted 2006) [#16]
And by the way the recommendation to use "/" instead of "\" is because it makes your code more portable I believe.


Moogles(Posted 2006) [#17]
yea its because of linux right? i remember that. thanks.


VP(Posted 2006) [#18]
You're advertising a competing product in your sig? Balls of steel, my friend. Balls of steel.


JazzieB(Posted 2006) [#19]
Yes, using the "/" instead of "\" is to maintain portability with both Linux and Mac.

Also, Chr(32) is a space, Chr(34) is a quote (").

And, I thought the the first cell reference in the LoadAnimImage command was so that you could choose whether to start numbering your loaded frames with 0, 1 or whatever you wanted (same as Blitz3D). Personally, I've always used 0 as the first indice of any array for the last 20 years, so using 1 seems unnatural to me. I could be wrong and I've not checked this, as I would never use 1.


Dreamora(Posted 2006) [#20]
sorry on the ascii number error. have no idea why i was on the 32 trip ...


tonyg(Posted 2006) [#21]
JazzieB, It seems the first_cell is the first frame in the file you want to load but it is still referenced by '0'.
If first-cell+cell_count > total_frames the image will not load.


TomToad(Posted 2006) [#22]
First cell refers to the cell number in the image file to start loading. Suppose you have several animations of your player in one .png file.
cells 0 - 15, player walking left
cells 16 - 31, player walking right
cells 32 - 47, player jumping left
etc...

Then you can load them like this.
Local PlayerWalkLeft:TImage = LoadAnimImage("Player.png",32,32,0,16)
Local PlayerWalkRight:TImage = LoadAnimImage("Player.png",32,32,16,16)
Local PlayerJumpLeft = LoadAnimImage("Player.png",32,32,32,16)
etc...

Actually you could have all your graphics in one huge .png file and load them this way.


tonyg(Posted 2006) [#23]
...and playerwalkright, in that example, will be drawn with...
drawimage playerwalkright,x,y,0-15


Moogles(Posted 2006) [#24]
wouldn't storing all my animations in one BIG file make it longer to access? Not to mention easy peasy for someone to just take. Id rather have all my animations split up.

Now im trying to figure out how to make an animation play depending on which key is being pressed.

You're advertising a competing product in your sig? Balls of steel, my friend. Balls of steel.


Not really advertising. Its there if someone wants to click it. Its not like Im saying Click Here! Balls of steel? I dont know about that ;)


tonyg(Posted 2006) [#25]
wouldn't storing all my animations in one BIG file make it longer to access? Not to mention easy peasy for someone to just take. Id rather have all my animations split up.


Some people refer to keep all the anims together and, if you use Indiepaths single-surface code, can speed access up. You can incbin it or pack it to make it more difficult for people to take. However, if somebody *really* wants it there's nothing much you can do anyway.

Not really advertising. Its there if someone wants to click it. Its not like Im saying Click Here! Balls of steel? I dont know about that ;)


Hmmm. Interesting argument.
The fact you have the same sig at CW *but* no BlitzMax logo in your Purebasic forum sig would suggest you're advocating Purebasic over BlitzMax hence advertising.
Let's face it, from your posts at CW it's obvious you're a Purebasic fan (and why not, it's a superb language) even at the expense of BlitzMax comments.

Personally, I don't really care what's in your sig but I think you're trying to be 'Draconusian clever'.


Yan(Posted 2006) [#26]
Balls of steel? I dont know about that ;)
Not dropped, more like. It's just rude and childish.


Moogles(Posted 2006) [#27]
Hmmm. Interesting argument.
The fact you have the same sig at CW *but* no BlitzMax logo in your Purebasic forum sig would suggest you're advocating Purebasic over BlitzMax hence advertising.
Let's face it, from your posts at CW it's obvious you're a Purebasic fan (and why not, it's a superb language) even at the expense of BlitzMax comments.

Personally, I don't really care what's in your sig but I think you're trying to be 'Draconusian clever'.



hehe. well i dont see it as advertising ;)
but thats my opinion. all i know is:
its my sig. its not alot of pictures. it doesnt violate forum rules. its 5 lines. end of.