Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebP image format on iOS

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.

like image 502
Soonts Avatar asked Dec 29 '11 19:12

Soonts


2 Answers

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

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

like image 186
Shmidt Avatar answered Oct 20 '22 16:10

Shmidt


WebP Image Support Coming to iOS 14

update your devices.

like image 23
Haseeb Javed Avatar answered Oct 20 '22 16:10

Haseeb Javed