02-21-2011 06:27 PM
I have a lot of images in my application. Is it possible to compress them even further than the compression rate of a bar file? Then what needed uncompress them accordingly.
Solved! Go to Solution.
02-21-2011 06:29 PM
02-22-2011 11:47 AM
I would say that since the BAR file is a zip file, you cant really get more compression than you are already getting. As it's already been suggested, you can reduce the size and quality of your images, but I don't think there is anything more you can do in terms of compression.
02-22-2011 11:56 AM
What Bill said, but I like to belabour a point...
In general, attempting to compress something that's already compressed will result in a net expansion in size.
An exception to this rule is if you have two compression algorithms involved, and one of them is better at compressing than the other. In this case, the JPEG compression knows about human perception of images and you can allow it to reduce quality (be more "lossy"), so it is capable of giving you a net improvement in compression.
If on the other hand you have large text files amongst your assets, and you think it's a good idea to pre-compress them using a compression algorithm similar to what the .bar files are using, then you should at least compare the before and after to make sure it's doing anything useful. More likely it's actually inflating the file and the extra complexity in your build process (and time decompressing in your app) isn't worth it.
That said, keep in mind that the .bar file is decompressed when it is installed on the PlayBook, so relying solely on the .bar file compression if you have very large and highly compressible files in your assets is a bad idea. You'd be keeping the download small and fast, but then using up way more of your user's disk space on the tablet than you could if you were able to compress said files ahead of time.
The same thing would probably apply to, for example, a pre-packaged SQLite database... only in this case since you'd probably be copying it from the app dir to the appstorage dir, you'd waste twice as much space. Definitely considering pre-compressing the assets in such a case, and decompress as/when you copy to appstorage when the app runs for the first time.
02-22-2011 12:46 PM
You can distribute your assets inside a BAR file as a ZIP file and access them from the ZIP as needed once the BAR is installed using an AS3 zip utility like fZip. Here's a sample that downloads a ZIP file of icons and displays the icons as the ZIP file is downloaded (this particular utitlity doesn't require the ZIP to be fully downloaded before accessing the data).
I'm not sure how much actual savings it would give you, so it may not be worth it. It definitely won't be worth it if your assets are large because AS3 is slow compared to native code and it will slow down your app.