Search code examples
iosperformanceuiimageviewuiimageantialiasing

Anti Alias, UIImage and Performance


I have a UIImage loaded into a UIImageView. The UIImage is larger than the UIImageView and it has been scaled down to fit. Obviously the scaled down UIImage shows jagged edges.

What is the best way to anti-alias this image with regards to performance?

I've seen this method using drawInRect but I've also read that drawInRect does not give the best performance.

I've read several different articles and I've tried a few methods myself. But after reading a few more posts on the performance differences between using UIViews and Core Graphics, I was wondering which method for anti aliasing an image gives the best performance?


Solution

  • Investigate the list of available Core Image Filters. Specifically, the Lanczos Scale Transform available via CILanczosScaleTransform seems to be exactly what you need. It should be available on all iOS versions >= 6.0.

    Typically, using Core Image filters will be more performant than manually resorting to Core Graphics. However, I urge you to verify the results as well as the performance in your specific case.