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.
I made full (decode/encode) UIImage
wrapper for WebP
.
https://github.com/shmidt/WebP-UIImage
WebP Image Support Coming to iOS 14
update your devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With