2012-03-15 1 views
1

私のiPhone画面のスクリーンショットを保存しようとしていますが、その結果は1倍になっています。iPhone iOS異なる解像度または縮尺のスクリーンショットをレンダリングするにはどうすればよいですか?

たとえば、320x480ピクセルのスクリーンショットは320x480ピクセルで、網膜ディスプレイに表示されると、ぼやけて見えます。しかし、ホーム画面と電源ボタンを使ってスクリーンショットを撮ると、640×960の画像が得られ、網膜の表示が完璧になります。 画面の倍率を考慮して、画面のスクリーンショットを取得するにはどうすればよいですか?

ありがとうございました!

+0

家庭や電源ボタンのないスクリーンショットを撮るにはどうすればよいですか? – Snowman

+0

プログラム的に。しかし、それは本質的に完全な解決でなければなりません。 – JoePasq

答えて

2
Try This: 

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) 
     UIGraphicsBeginImageContextWithOptions(self.window.bounds.size, NO, [UIScreen mainScreen].scale); 
    else 
     UIGraphicsBeginImageContext(self.window.bounds.size); 

    [self.window.layer renderInContext:UIGraphicsGetCurrentContext()]; 
     UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
     UIGraphicsEndImageContext(); 
     NSData * data = UIImagePNGRepresentation(image); 
     [data writeToFile:@"foo.png" atomically:YES]; 
関連する問題