I'm trying to load and decode
an image as fast as possible while having some way of cancelling the operation while executing. I currently use CGImageCreateWithPNGDataProvider
to get the data followed by CGBitmapContextCreate/CGContextDrawImage
to force the decode. I then create a UIImage with the resulting CGImageRef
bitmap.
A problem with this approach is that the drawing call can take up to a few seconds to return for very large images. If my app determines that the image is no longer needed, I have no way of cancelling the operation to give the resources to other images that need to be loaded.
Is there any way of rendering an image in multiple steps without sacrificing too much performance? I have tried rendering the image in parts using CGImageCreateWithImageInRect
, but doing so took up to 10-20 times as long as rendering the image in one pass.
Any input on the subject is greatly appreciated!