Incbin issue

BlitzMax Forums/BlitzMax Beginners Area/Incbin issue

Kanati(Posted 2011) [#1]
Incbin "graphics\redleft.png"
Global redleft:TImage = LoadImage("incbin::redleft.png")


That results in redleft being null. I've never fiddled with incbin before but what I've seen indicates that that should work, no?


GfK(Posted 2011) [#2]
No.

Try LoadImage("incbin::graphics\redleft.png")


Kanati(Posted 2011) [#3]
Oh. I might add that if I change "incbin::redleft.png" to "graphics\redleft.png" it works fine so I know the image is getting loaded.


Kanati(Posted 2011) [#4]
ah. Thanks. I didn't realize it would keep the directory structure as well.


xlsior(Posted 2011) [#5]
That's by design: if you include the folder path in the incbin statement, you have to retrieve it using the same (virtual) folder path as well.


GfK(Posted 2011) [#6]
Yep - its especially handy as it lets you do this:
Global datapath:String = "incbin::"
Include "incbin.bmx" ' list of incbinned files in here
'datapath = ""

LoadImage(datapath + "graphics\redleft.png")


Why is this handy? Well, if you've got a lengthy program with hundreds of incbinned files, it will take ages to compile. When debugging its streamlines things a bit more if you comment out the second line, and uncomment the third line - forcing it to bypass incbin completely and load files from their respective folders.


Kryzon(Posted 2011) [#7]
Very clever! makes perfect sense.


Midimaster(Posted 2011) [#8]
Did you ever try the combination with Koriolis.ZipStream.Mod? I use it since years and it is very comfortable.

with Koriolis.ZipStream.Mod you have to incbin only one file: a ZIP-File, where all your files are packed.

An this is the code:

If you add your files to a ZIP without path structure:
SuperStrict   
Import koriolis.zipstream
Incbin "MyFiles.ZIP"
' DataPath = "graphics\"
DataPath="ZIP::Incbin::MyFiles.ZIP//"


and swap to direct loading, as GfK told you:

SuperStrict   
Import koriolis.zipstream
' Incbin "MyFiles.ZIP"
DataPath = "graphics\"
' DataPath="ZIP::Incbin::MyFiles.ZIP//"


but you also could add the files to the ZIP including the path structure. Then use this code:
SuperStrict   
Import koriolis.zipstream
Incbin "MyFiles.ZIP"
' DataPath = "graphics\"
DataPath="ZIP::Incbin::MyFiles.ZIP//graphics\"



Kanati(Posted 2011) [#9]
Interesting. I might look into that. Thanks.


xlsior(Posted 2011) [#10]
As a side-note: koriolis' mod also supports password protected zip files, so you can add an additional layer of protection if you are concerned about your media files.