Pie*_*rre 9 screenshot objective-c ipad ios retina-display
在我的应用程序中,我使用的是截图方法.在我的iPad 2上执行此方法的速度非常快(约130毫秒).但是在新的iPad上(当然由于最高的分辨率和相同的CPU),它需要700毫秒!有没有办法优化我的方法?也许有办法直接使用显卡吗?
这是我的截图方法:
- (UIImage *)image {
CGSize imageSize = self.bounds.size;
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(imageSize, NO, [UIScreen mainScreen].scale);
else UIGraphicsBeginImageContext(imageSize);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextTranslateCTM(context, [self center].x, [self center].y);
CGContextConcatCTM(context, [self transform]);
CGContextTranslateCTM(context, -[self bounds].size.width * [[self layer] anchorPoint].x, -[self bounds].size.height * [[self layer] anchorPoint].y);
[[self layer] renderInContext:context];
CGContextRestoreGState(context);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
Run Code Online (Sandbox Code Playgroud)
}
谢谢你的帮助.
我认为是 Flipboard 的开发者在播客上谈论了这个问题。这是 iPad 3 的一个真正问题,因为它们的像素增加了四倍。
他所做的是提前在后台截取屏幕截图,而不是在用户发起操作时截取屏幕截图 - 在他的例子中,是在用户“翻转”页面时截取屏幕截图。
我不知道这对您的情况是否有帮助,但对于许多情况来说这肯定是一种可行的方法。
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           1331 次  |  
        
|   最近记录:  |