0

2 つの画像を結合したいのですが、BaseImages のサイズが 1280*1920 の場合、メソッドを使用して 1 つの画像に変換しましたが、新しい画像のサイズは 320*480 になります。元のピクセルとサイズが欲しい

私はこのコードを使用しました:

//  ImageContainView  - UIView that Contains 2 UIImageView. View size :- 320*480

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

ベース画像サイズ 1280*1920

4

1 に答える 1

1

あなたがやろうとしていることを正しく理解している場合、小さな画像を取得している理由は、小さなサイズでコンテキストを初期化しているためです:

UIGraphicsBeginImageContext(imageContainView.bounds.size);

imageContainView.bounds.sizeが 320x480 の場合、320x480 の画像が得られます。

したがって、次のように呼び出す必要があります。

UIGraphicsBeginImageContext(correctImageSize);

どこcorrectImageSizeで CGSizeMake(1280,1920)、またはあなたが持っているより大きな画像のサイズです。

または、前に電話してみることができますsizeToFit

[imageContainView sizeToFit];
UIGraphicsBeginImageContext(imageContainView.bounds.size);
于 2012-10-23T08:25:00.883 に答える