CGContextDrawImage 在 iPhone 4 上非常慢 [英] CGContextDrawImage very slow on iPhone 4

查看:22
本文介绍了CGContextDrawImage 在 iPhone 4 上非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 CGBitmapContextRef 用于大型可变图像.比我在 UIView.drawRect 中绘制一个部分.这在 iPhone 3GS - 17FPS 上运行良好.但是在 iPhone 4 上调用 subj 方法非常慢 - 总 FPS 为 1.5!

I use CGBitmapContextRef for large alterable image. Than I draw one's parts in UIView.drawRect. That's work well on iPhone 3GS - 17FPS. But on iPhone 4 calling subj method is very slow - and total FPS is 1.5!

分析器说:在 3GS 上调用 CGSBlendBGRA8888toRGBA8888,这需要 23% 的总时间.在 4G 上,相同的代码调用 argb32_sample_RGBA32/argb32_image_mark,它占了大约 90%.哇!

profiler says that: on 3GS invokes CGSBlendBGRA8888toRGBA8888 which takes 23% of total time. on 4G same code invokes argb32_sample_RGBA32/argb32_image_mark which takes ~90%. wow!

位图的颜色空间是 CGColorSpaceCreateDeviceRGB.创建标志是 kCGImageAlphaPremultipliedLast.

Color space for bitmap is CGColorSpaceCreateDeviceRGB. And creating flag is kCGImageAlphaPremultipliedLast.

我该怎么做才能在 iPhone 4 上获得更好的性能?有什么建议吗?

What can I do for better performance on iPhone 4 ? Any suggestions ?

推荐答案

尝试设置:

CGContextSetInterpolationQuality(myBitmapContext, kCGInterpolationNone);

在您的位图上.kCGInterpolationLow 是另一种选择.

on your bitmap. kCGInterpolationLow is another option.

另一种可能有帮助的技术是将 CALayer 添加到您的视图中,并将 CALayer 的内容设置为您的位图,而不是在视图的 drawRect 内绘制位图图像.

Another technique that may help is add a CALayer to your view, and to set the CALayer's contents to your bitmap, instead of drawing the bitmap image inside the view's drawRect.

这篇关于CGContextDrawImage 在 iPhone 4 上非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆