亲爱的学者们,
我正在使用以下代码来捕捉屏幕并将其保存为jpg格式到相册中 - 这很好用。
然而,在iPhone 4上运行时,由于更高的分辨率,捕获的屏幕仅为320X480,(我认为在iPad上也是如此)。
我该如何解决这个问题?
// Save the captured image to photo album
- (IBAction)saveAsJPG
{
UIImage *image = [self captureView:self.view];
UIImageWriteToSavedPhotosAlbum(image, self,
@selector(image:didFinishSavingWithError:contextInfo:), nil);
}
-(UIImage *)captureView:(UIView *)view
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, screenRect);
[view.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}