Page 1 of 1

Compression/Decompression Question

Posted: Sun Oct 12, 2003 7:35 pm
by DriakTravo
:?: Is there any way in Purebasic that you can compress many files into one and use it in a purebasic program. Example: if I wanted to compress 5 sprite bitmaps and 2 wav sound files into one file and use it in a game. :?:

I give many thanks to any help. :)

Posted: Sun Oct 12, 2003 7:51 pm
by Paul
Have you looked at PureInstall ??

http://www.reelmediaproductions.com/pureinstall

You could also IncludeBinary your files and then UPX your compiled app.

Posted: Sun Oct 12, 2003 7:55 pm
by DriakTravo
Hmmm... Thanks! That will prove to be very usefull to me! :lol: What I meant tho was put 5 bmp and 2 wav into one file and use the file in PureBasic.

Posted: Sun Oct 12, 2003 9:09 pm
by Seldon
I think the best solution is to compress each file you need (a .bmp , a .wav , etc.. ) with PackMemory() and then you include each compressed file in your program with IncludeBinary. At run-time you decompress each file. Instead of using IncludeBinary, you could add the compressed files as resources. That would be better since you won't waste memory. See in the Tips&Tricks section how to load a file from resources.

Posted: Sun Oct 12, 2003 9:09 pm
by Proteus
You could use the packer stuff...

Don't ask me how though. I've never tried them.

Posted: Mon Oct 13, 2003 1:33 am
by DriakTravo
I tried using the packer but I couldn't get it to work. I guess im just not that good yet. :? Mabe one day someone will teach me :wink: wink wink nudge nudge

Posted: Mon Oct 13, 2003 1:37 am
by Kale
easy! 'binary include' your media into your exe, then download UPX.exe, lob it in your windows folder, then on the command line from a CMD prompt, type 'UPX --best APPNAME.exe'.

Easy! :)

Posted: Mon Oct 13, 2003 10:25 am
by Fred
The packer lib is here for that: you create the pak file, add some file with AddPackFile() and then use the CatchSound()/CatchSprite() commands when reading it back. If you need more info, tell me..

Posted: Mon Oct 13, 2003 12:01 pm
by lethalpolux
Yep,
you create your pak file:

createpack("mycompressedfiles.pak")

; you add your files

addpackfile("Image1.bmp")
addpackfile("Image2.bmp")
addpackfile("mywave1.wav")
addpackfile("mywave2.wav")

closepack()

you execute this code to compress the files.. After in your program:

openpack("mycompressedfiles.pak")

catchsprite(0,nextpackfile())
catchsprite(1,nextpackfile())
catchsound(0,nextpackfile())
catchsound(1,nextpackfile())

closepack()

It's ready to use...:wink:

Posted: Mon Oct 13, 2003 3:24 pm
by Andre
Just added to the manual, thanks lethalpolux :D

Posted: Mon Oct 13, 2003 4:56 pm
by DriakTravo
Thank you all so much for all of your help! :) It is greatly thanked!