Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
noahnu
Posts: 138
Registered: ‎01-09-2011
My Device: Blackberry Tablet OS
Accepted Solution

Compression?

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.

From,
Noah NU
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Compression?

Most image formats are pretty compressed already.  What file formats are you including?  If you have JPEG, you can reduce the quality to 50-60% and the image can still look pretty good and reduce the filesize down significantly.

Please use plain text.
Developer
noahnu
Posts: 138
Registered: ‎01-09-2011
My Device: Blackberry Tablet OS

Re: Compression?

The images are JPEGs and PNGs.

 

Quality doesn't matter that much anyway for the needs of my applications. Thank you.

From,
Noah NU
Please use plain text.
Developer
billfoust
Posts: 382
Registered: ‎05-19-2008
My Device: BlackBerry Torch
My Carrier: AT&T

Re: Compression?

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.

 

Bill

 

Bill
-------------------------------------------
Check out my book on BlackBerry Development for Java.
And my other really really old book
My Apps: FlashKids
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Compression?

What Bill said, but I like to belabour a point... :smileyhappy:

 

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.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
studiochris
Posts: 165
Registered: ‎10-26-2010
My Device: BlackBerry® PlayBook™
My Carrier: .

Re: Compression?

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).

 

http://codeazur.com.br/lab/fzip/demo/

 

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.

Please use plain text.