0

私のアプリケーションでは、カメラから画像をキャプチャします。その時、私の画像の鮮明さは素晴らしいですが、次のコード行で私の画像は次のビューに移動します。

- (UIImage *) imageFromView:(UIView *)view {

    UIGraphicsBeginImageContext(view.bounds.size);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return viewImage;
}

その時の次のビューで画像を見ると、以前よりも鮮明ではありません。

言及したいのですが、どちらの画面でも画像ビューの高さと幅は同じです。

では、画像の鮮明さの問題は何でしょうか?

4

2 に答える 2

2

この行を使用する

UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.0);

それ以外の
UIGraphicsBeginImageContext(view.bounds.size);

于 2012-12-18T06:14:02.113 に答える
0

画像を0.5,0.5オフセットする必要があります。それ以外の場合、Quartzは各ポイントを4つのネイバーに分散します。

Quartzでは、0.0はピクセルの中心ではなく、角です。

CGContextTranslateCTM(context, 0.5, 0.5);

参照:https ://developer.apple.com/library/mac/ipad/#documentation/graphicsimaging/reference/CGContext/Reference/reference.html

于 2012-12-18T05:57:26.137 に答える