En mi aplicación estoy usando un método de captura de pantalla. En mi iPad 2 es muy rápido (alrededor de 130 ms) para ejecutar este método. Pero en el nuevo iPad (sin duda debido a la resolución más alta y la misma CPU) ¡está tardando 700 ms! ¿Hay alguna forma de optimizar mi método? Tal vez hay una forma de trabajar directamente con la tarjeta gráfica.iPad 3 lenta captura de pantalla
Aquí es mi método de captura de pantalla:
- (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;
}
Gracias por su ayuda.
No puedo ayudarlo aquí. Pero creo que 700ms es realmente lento. ¿No debería ser como 130ms * 4 = 520ms? –
Intente utilizar 'UIGraphicsBeginImageContextWithOptions (imageSize, NO, 0.0f);' en lugar de 'UIGraphicsBeginImageContextWithOptions (imageSize, NO, [UIScreen mainScreen] .scale);'. Esto hará una captura de pantalla 1: 1. ¿O hay una razón específica por la que necesita '[UIScreen mainScreen] .scale' allí? –
@Jenox sí, depende, pero se parece más a 700ms. – Pierre