私のアプリでは、スクリーンショットの方法を使用しています。私のiPad 2では、この方法を実行するのに非常に高速です(約130 ms)。しかし、新しいiPad(確かに最高の解像度と同じCPUのために)で、それは700ミリ秒のように取っている!メソッドを最適化する方法はありますか?おそらくグラフィックカードで直接作業する方法がありますか?あなたの助けのためのiPad 3 slow screenshot
- (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;
}
ありがとう:
は、ここに私のスクリーンショット方法です。
ここをクリックしてください。しかし、私は700msが本当に遅いと思います。 130ms * 4 = 520msのようにはならないのですか? –
'UIGraphicsBeginImageContextWithOptions(imageSize、NO、[UIScreen mainScreen] .scale);'の代わりに 'UIGraphicsBeginImageContextWithOptions(imageSize、NO、0.0f);を使ってみてください。 これは1:1のスクリーンショットになります。または、そこに '[UIScreen mainScreen] .scale'が必要な特別な理由がありますか? –
@ジェノックスええそれは依存しますが、それはもっと700msのようです。 – Pierre