A Simple, Clean, File Packer.

BlitzMax Forums/BlitzMax Programming/A Simple, Clean, File Packer.

Vagary Labs(Posted 2009) [#1]
Greetings!

I've been browsing around the forums and trying little clues that may sound good, but I keep on ending up empty handed. Either the link doesn't work or it says it supports BlitzMax and it doesn't.

I am looking for a simple, clean, file packer. I would prefer it to be able to support lots of different file types. If it can only hold images, I'd like one that can contain PNG files and keep the alpha mask intact. Anyone know of any good ones?

Thanks for your help!
Mr.Wolf


therevills(Posted 2009) [#2]
What about just using IncBin?


Vagary Labs(Posted 2009) [#3]
I've thought about that, but I'm guesstimating, that I'm going to have 100+ MB of data when the project is done! O_O

Thanks for your input though!
Mr.Wolf


Zeke(Posted 2009) [#4]
http://www.blitzmax.com/codearcs/codearcs.php?code=2249


xlsior(Posted 2009) [#5]
Regardless of what packer you go with, realize that PNG's are already heavily compressed internally, and you're unlikely to be able to get more than a couple of percent additional compression out of it regardless of what algorithm you use.

(the only reason that other formats like JPG can be much smaller is that PNG is lossless and keeps 100% quality, while JPEG throws away information at the cost of image quality)

for general purpose packing stuff, I like Koriolis' zipstream module -- you can put your files inside a standard zip file, but blitzmax can read its contents just like if it were any normal stand-alone uncompressed file. Compatible with incbin as well, and support password-protected zipfiles if you're worried about protecting your assets.

download link:
http://www.koriolis-fx.com/forum/index.php?topic=15.0

(You'll need to sign up for a free account and log in to see the download link to the library)


Vagary Labs(Posted 2009) [#6]
Yeah, I'm not really looking for any type of compression, but rather something to store the files in. Eg. take 500 images and have 1 file of them within the file.

I'm going to have to check this one out. ^_^

Thanks for your help!
Mr.Wolf


Vagary Labs(Posted 2009) [#7]
***UPDATE***
This is exactly what I was looking for!

Thanks Xlsior! ^_^


xlsior(Posted 2009) [#8]
Yeah, I'm not really looking for any type of compression, but rather something to store the files in. Eg. take 500 images and have 1 file of them within the file.


Sounds like this might work just fine for you then -- if you're not expecting to benefit from compression, just use zip files without compression to get the maximum speed (no decompression overhead that way)

The nice thing about the zipstream module is that it just adds another stream type: zip::
You can access the zip file as if it were a folder, and all the Blitzmax file read commands like readfile, loadimage, etc. can open the packed images just by referring to them like this:

img=loadimage("zip::myzipefile.zip//somefile.png")

Pretty much a drop-in solution that way, without any weird custom loading commands that you'll have to juggle data through.

you can even include the zip file straight in your executable by chaining it with incbin, plus you can use folders inside of the zip file to organize your data:

img=loadimage("zip::incbin::myzipefile.zip//somezippedfolder/somefile.png")
(The actual syntax might be slightly different, but that's more or less how it works)