2

我正在使用尺寸为 320X320 的 imagview 来显示大图像(350 X 783)。

将大图像放入图像视图时,图像看起来被挤压,压缩的东西不像质量。

我的问题是,如何将大图像制作成与原始图像一样质量的小图像?

4

3 回答 3

4

您可以将图像视图设置为适当的内容模式,就像这样

        imageView.contentMode = UIViewContentModeScaleAspectFit
于 2013-02-15T09:43:36.273 回答
1
-(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;
}
于 2013-02-15T10:02:08.187 回答
0

你可以这样做,

    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;
于 2013-02-15T09:54:58.253 回答