Hacker News new | past | comments | ask | show | jobs | submit login
Extracting images from Apps in the AppStore (idevrecipes.com)
15 points by admp on Jan 15, 2011 | hide | past | web | favorite | 5 comments



Does he mean optimize or obfuscate?


He really does mean 'optimize'.

There is a command-line utility that is run during Xcode app builds called 'pngcrush'. It was originally written by somebody else, then modified a bit for Apple's use. It tries to further compress png files and, I think, reorganizes them so that they can be more efficiently rendered by the iPhone's GPU. Like, maybe so they can be drawn bottom-to-top, rather than the usual top-to-bottom? I read about this once, but it was years ago, and I can't remember all the details.


It reorders the bytes of the image from RGBA to BGRA, which is the natural byte order used by the GPU (other byte orders are supported, but have to get swapped when loaded). Also, it premultiplies each color channel by the alpha channel. So if you have a blue pixel with a 50% alpha (RGBA 00 00 FF 80) it gets converted to (BGRA 80 00 00 80). After that, it uses the usual pngcrush method of trying all different compression settings until it finds the smallest size. So it's optimized both in terms of size and speed of rendering.


The major optimization is that it converts images to 32bpp and premultiplies them.





Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: