iPad 3 renderInContext慢 - 渲染性能不佳 [英] iPad 3 renderInContext slow - Bad rendering performance

查看:211
本文介绍了iPad 3 renderInContext慢 - 渲染性能不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从用户可以绘制的视图中获取图像,或者添加一些其他视图。随着iPad1& 2到目前为止一切正常。
但是在iPad3上它像狗一样运行。
我只是使用图层renderInContext方法。

I am trying to get an image out of a view where a user can paint on, or add some other views. With the iPad1 & 2 everything is working fine so far. But on the iPad3 it runs like a dog. I am just using the layers renderInContext method.

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
    UIGraphicsBeginImageContextWithOptions(self.viewDrawableViewContainer.frame.size, NO, [UIScreen mainScreen].scale);
else
    UIGraphicsBeginImageContext(self.viewDrawableViewContainer.frame.size);
[self.viewDrawableViewContainer.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();   

我知道这可能是因为cpu等于ipad2的一个,
但它需要大约1秒钟。用户绘制或添加的越多,渲染所需的时间就越长。有时长达5秒,这是非常不可接受的。
那么有什么选择可以提高性能吗?
任何可能设置较小渲染质量的机会 - 我不需要在最高视网膜分辨率下渲染...

I know this is probably caused by the cpu which is equal to the ipad2 one, but it takes about 1 second. The more the user paints or adds, the longer it will take to render. Sometimes up to 5 seconds which is really inacceptable. So are there any options to improve performance? Any chance to maybe set a smaller rendering quality - I don't need a rendering in the highest retina resolution...

我将不胜感激任何帮助!提前致谢

I would appreciate any help! Thanks in advance

推荐答案

您可以通过以较低分辨率渲染来提高速度。使用小于1.0的UIGraphicsBeginImageContextWithOptions比例因子,例如0.5。

You can increase speed by rendering at lower resolution. Use a UIGraphicsBeginImageContextWithOptions scale factor less than 1.0, e.g. 0.5.

此外,如果你不需要alpha,你可以通过为不透明标志传递YES来获得小的速度提升。我自己没有时间差异。

Also, if you don't need alpha you might get a small speed boost by passing YES for the opaque flag. I haven't timed the difference myself.

这篇关于iPad 3 renderInContext慢 - 渲染性能不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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