CGContextDrawImage对iPhone 4非常缓慢 [英] CGContextDrawImage very slow on iPhone 4

查看:409
本文介绍了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相同的code调用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。和创建标志kCGImageAlpha premultipliedLast。

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天全站免登陆