サイズが 320X320 の imagview を使用して大きな画像 (350 X 783) を表示しています。
大きな画像をイメージビューに配置している間、画像は圧縮されたように見え、品質のものとは異なります。
私の質問は、元の画像と同じ品質で大きな画像を小さくするにはどうすればよいですか?
サイズが 320X320 の imagview を使用して大きな画像 (350 X 783) を表示しています。
大きな画像をイメージビューに配置している間、画像は圧縮されたように見え、品質のものとは異なります。
私の質問は、元の画像と同じ品質で大きな画像を小さくするにはどうすればよいですか?
そのように、画像ビューを適切なコンテンツモードに設定できます
imageView.contentMode = UIViewContentModeScaleAspectFit
-(UIImage*)scaleToSize:(CGSize)size {
// Create a bitmap graphics context
// This will also set it as the current context
UIGraphicsBeginImageContext(size);
// Draw the scaled image in the current context
[self drawInRect:CGRectMake(0, 0, size.width, size.height)];
// Create a new image from current context
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
// Pop the current context from the stack
UIGraphicsEndImageContext();
// Return our new scaled image
return scaledImage;
}
あなたはこのようにすることができます、
UIImage* sourceImage = "yourImage";
CGSize newSize=CGSizeMake(80,80);
UIGraphicsBeginImageContext( newSize );
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
yourImageView.image=newImage;