私は後でやiPad 3あなたがUIGraphicsBeginImageContextWithOptionsを使用して、網膜の解像度(960x640または2048×1536)でキャプチャのUIView/UIWindowを必要と推測し、その尺度パラメータは0.0fは、それが本来の解像度でキャプチャします設定(iPhone 4のための網膜と)。
このコードは、ネイティブ解像度この1つはフルスクリーン(キーウィンドウ)
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
CGRect rect = [keyWindow bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[keyWindow.layer renderInContext:context];
UIImage *capturedScreen = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
これは、95%の品質をJPG形式でUIImageを節約のために同じことを
CGRect rect = [captureView bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[captureView.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
であなたのUIViewをキャプチャアプリのドキュメントフォルダ
NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/capturedImage.jpg"]];
[UIImageJPEGRepresentation(capturedImage, 0.95) writeToFile:imagePath atomically:YES];
これも試すことができます。UIGraphicsBeginImageContextWithOptions(view.bounds.size、view.opaque、0.0); –
ありがとうございますが、何も変わりません! –
「低品質」と言うとき、正確に何を意味していますか?画像は画面上のものと同じに見えませんか?あなたは網膜ディスプレイを使用していますが、キャプチャされた画像はシャープではありませんか?画像が粒状であるか歪んでいますか?それは何が間違っていますか? – TigerCoding