views:

66

answers:

5

Is there any good library for lossless image encoding/decoding that has compression rate more or less similar to PNG but decoding to raw RGB bitmap data would be much faster than PNG?

Also alpha transparency is needed, but not essential because, alpha channel could be taken from separate image.

Original problem lies in slowness of reading and decoding PNG files on iPhone using standard libraries. Obvious and the simples solution would have been storing raw RGB bitmap data, but then size of unpacked ipa is too large - 4 times larger than PNG files. So, I am trying to find some compromise solution.

+1  A: 

Why not just use the original raw RGB(A) data and compress and decompress it with zip, RLE, huffman etc?

Andreas Brinck
+1. If you want lossless, this is about as good as you can do.
Jason
A: 

ImageMagick is a fairly popular library for image processing. I doubt you'll be able to do this on an actual iPhone though.

armandino
A: 

Unless your images are constrained to a specific problem domain (e.g. computer generated screenshots) where a customized solution may be able to satisfy both compression ratio and speed of decoding objectives, these are generally tradeoffs where you'll have to choose between one or the other.

PNG compression is using entropy encoding techniques under the covers so re-implementing that on you own is unlikely to help.

You may pursue some sort of programmatic solution that "hides" the slowness from the user by lazy loading the images in a separate thread.

jeff7
+1  A: 
Norman Ramsey
A: 

PNG compression is a a basic prediction (neighbour pixels) followed by Zip compression. If you really need lossless compression with low memory-CPU requirements, that strategy it's hard to beat... asumming you have a decent PNG creating library. The encoding bottleneck is the zip compression. (And, as another one has pointed out, bear in mind that decoding is much faster than coding). To just zip the raw image would be only marginally faster, and (except for very particular images) attain much lower compression efficiency.

leonbloy
Encoding could be slow, for me critical is the decoding time - which is loading time of a game.
Dmitry