WebP image format on iOS

Soonts picture Soonts · Dec 29, 2011 · Viewed 26.8k times · Source

I’m currently researching the possibility to use Google’s WebP image format in our iOS software.

I found it’s not hard to decode the WebP into RGBA8888 as needed using the Google’s C-library.

However, I’d like to create an implementation comparable to UIImage in terms of both API and performance.

Q1. Is it possible in iOS to develop an image decoder so that native imageWithData and other APIs will read the new format?

Q2. If no, what API does UIImageView (and other framework-provided controls) use to draw the UIImage? Is it public (e.g. drawInRect/drawAtPoint) or internal?

Can I inherit from UIImage, override a few methods (such as +imageWithContentsOfFile, +imageWithData, +imageNamed, -drawInRect, -drawAtPoint), and have my WPImage objects behave well with SDK-provided APIs?

Q3. If every instance of my hypothetical WPImage class will subscribe for UIApplicationDidReceiveMemoryWarningNotification (to flush RGBA image buffer leaving the much smaller original WebP data in RAM), won’t it hurt the performance much?

The software we’re developing may easily have hundreds of different images in RAM.

Answer

Shmidt picture Shmidt · Aug 2, 2013

I made full (decode/encode) UIImage wrapper for WebP.

https://github.com/shmidt/WebP-UIImage