具有 CGContextSetInterpolationQuality 的图像质量
Quartz 中的 CGContextSetInterpolationQuality 方法有多有效?
它会影响图像质量吗?如果是这样,程度如何?
我看不出插值图像和非插值图像之间有任何区别。
How effective is the CGContextSetInterpolationQuality
method in Quartz?
Does it affect the quality of the image? If so, to what extent?
I can't see any difference between the interpolated and the non-interpolated image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然这是一个有点老的问题,但我最近对 CGContextSetInterpolationQuality 的效果进行了一些基准测试,并认为其他人可能会对它的结果感兴趣。
在我的基准测试中,我绘制了一组 6 个不同的 649x649 黑白位图图像来构建一组 12 个不同的拼图块。位图图像按比例缩小 5.0 倍(即缩小到 129.8x129.8),以使其适合 320x480 显示屏(视网膜显示比例)。
根据 Instruments 的报告,第四代 iPod touch 上的运行时间如下:
kCGInterpolationLow:969 毫秒
kCGInterpolationMedium:1690 毫秒
kCGInterpolationHigh:2694 毫秒
kCGInterpolationNone: 545 msec
至于视觉结果,如果将“高”或“中”与“低”或“无”进行比较,差异是惊人的。在我看来,无和低之间的区别甚至很明显;而在这个特定的测试中,高和中之间的差异并不是特别明显。显而易见的是运行时间的差异,因此在我的特定情况下,我最终使用了 kCGInterpolationMedium。
kCGInterpolationNone
kCGInterpolationLow
kCGInterpolationMedium
kCGInterpolationHigh
Although this is a bit of an old question, I have recently done some benchmarking about the effects of
CGContextSetInterpolationQuality
and thought that its outcomes might be of interest to someone else.In my benchmark test, I draw a set of 6 different 649x649 b&w bitmap images to build a set of 12 different jigsaw puzzle tiles. The bitmap images are scaled down by a factor of 5.0 (i.e., to 129.8x129.8) to make them fit on a 320x480 display (at retina display scale).
Run times on a 4th gen iPod touch, as reported by Instruments, are the following:
kCGInterpolationLow: 969 msec
kCGInterpolationMedium: 1690 msec
kCGInterpolationHigh: 2694 msec
kCGInterpolationNone: 545 msec
As to the visual outcome, if you compare High or Medium to Low or None, the difference is staggering. Even noticeable, IMO, the difference between None and Low; while the difference between High and Medium is not particularly noticeable in this particular test. What is clear is the difference in run times, so that in my particular case, I ended up using
kCGInterpolationMedium
.kCGInterpolationNone
kCGInterpolationLow
kCGInterpolationMedium
kCGInterpolationHigh
方法
void CGContextSetInterpolationQuality (CGContextRef c, CGInterpolationQualityquality);
影响Quartz将图像渲染到
CGContext
的方式。例如,当源图像大于或小于目标位图 CGContext 时,此功能就会发挥作用。为了准确回答您为什么没有看到任何明显差异的问题,我需要有关确切用法、图像大小、上下文类型等的更多详细信息。
不同质量级别涵盖的插值方法到底是什么似乎没有记录。然而,我的猜测是:
问候
The method
void CGContextSetInterpolationQuality ( CGContextRef c, CGInterpolationQuality quality );
affect the way Quartz renders an image into a
CGContext
. This e.g. comes into play when the source image is larger or smaller than the target bitmapCGContext
.To exactly answer your question of why you don't see any noticable difference, I will need more details about the exact usage, image sizes, context types, etc.
Exactly what interpolation methods the different quality levels cover seems undocumented. A guess from my side would however be:
Regards