Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad 3 slow screenshot

In my app I'm using a screenshot method. On my iPad 2 it's very fast (about 130 ms) to execute this method. But on the new iPad (certainly due to the highest resolution and the same CPU) it's taking like 700 ms ! Is there a way to optimize my method ? Perhaps there's a way to work directly with graphic card ?

Here's my screenshot method :

- (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;

}

Thanks for your help.

like image 899
Pierre Avatar asked Apr 04 '12 07:04

Pierre


1 Answers

I think it was the developer of Flipboard talking about this issue on a podcast. It is a real issue with the iPad 3, because they've quadrupled the pixels.

What he was doing was taking the screenshot ahead of time in the background, not when the user initiated the action - in his case when the user "flipped" the page.

I don't know whether this will help you in your case, but it is certainly a viable approach for many cases.

like image 94
Nick Pestov Avatar answered Sep 27 '22 21:09

Nick Pestov