抗锯齿、UIImage 和性能 [英] Anti Alias, UIImage and Performance
问题描述
我有一个 UIImage
加载到 UIImageView
中.UIImage
比 UIImageView
大,并且已经缩小以适应.显然,缩小后的 UIImage
显示出锯齿状边缘.
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.
在性能方面消除此图像锯齿的最佳方法是什么?
我见过这个方法使用drawInRect
但我也读过 drawInRect
并没有提供最佳性能一>.
I've seen this method using drawInRect
but I've also read that drawInRect
does not give the best performance.
我阅读了几篇不同的文章,我自己也尝试了一些方法.但是在阅读了很少更多 帖子关于使用UIViews
和 Core Graphics,我想知道哪种图像抗锯齿方法可以提供最佳性能?
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?
推荐答案
调查可用的列表 核心图像过滤器.具体来说,通过 CILanczosScaleTransform
提供的 Lanczos Scale Transform 似乎正是您所需要的.它应该适用于所有 >= 6.0 的 iOS 版本.
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.
通常,使用 Core Image 过滤器会比手动求助于 Core Graphics 的性能更高.但是,我敦促您验证结果以及特定情况下的性能.
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.
这篇关于抗锯齿、UIImage 和性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!