Compression/Decompression Question

Advanced game related topics
DriakTravo
Enthusiast
Enthusiast
Posts: 346
Joined: Fri Oct 10, 2003 12:42 am
Location: Tampa,FL,USA
Contact:

Compression/Decompression Question

Post 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. :)
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1286
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Have you looked at PureInstall ??

http://www.reelmediaproductions.com/pureinstall

You could also IncludeBinary your files and then UPX your compiled app.
Image Image
DriakTravo
Enthusiast
Enthusiast
Posts: 346
Joined: Fri Oct 10, 2003 12:42 am
Location: Tampa,FL,USA
Contact:

Post 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.
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

Post 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.
Proteus
Enthusiast
Enthusiast
Posts: 113
Joined: Wed Sep 17, 2003 8:04 pm
Location: The Netherlands

Post by Proteus »

You could use the packer stuff...

Don't ask me how though. I've never tried them.
P4 2.4GHz, 256 MB, WinXP Pro, onboard video&audio.
The Programmer's Drinking Song:
"99 little bugs in the code,
99 little bugs.
Fix one bug, recompile
100 little bugs in the code."
DriakTravo
Enthusiast
Enthusiast
Posts: 346
Joined: Fri Oct 10, 2003 12:42 am
Location: Tampa,FL,USA
Contact:

Post 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
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post 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! :)
--Kale

Image
Fred
Administrator
Administrator
Posts: 18384
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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..
lethalpolux
Enthusiast
Enthusiast
Posts: 171
Joined: Sun Jun 08, 2003 10:50 pm
Location: France
Contact:

Post 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:
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2148
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Post by Andre »

Just added to the manual, thanks lethalpolux :D
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
DriakTravo
Enthusiast
Enthusiast
Posts: 346
Joined: Fri Oct 10, 2003 12:42 am
Location: Tampa,FL,USA
Contact:

Post by DriakTravo »

Thank you all so much for all of your help! :) It is greatly thanked!
Post Reply