0

我知道这个问题已经被问过很多次了,但不知道为什么我的 UIImage 仍然模糊。

我做了什么:

尽管如此,出现在屏幕上的 UIImage 还是有点模糊。任何想法我做错了什么?

代码:

UIImage *gotImage = [info objectForKey:UIImagePickerControllerOriginalImage];

float scale = (self.view.frame.size.width)/(imageToResize.size.width);
imageToResize = [imageToResize resizedImage:CGSizeMake(scale * imageToResize.size.width, scale * imageToResize.size.height) interpolationQuality:kCGInterpolationHigh];

UIImageView *background = [[UIImageView alloc] initWithImage:imageToResize];
background.contentMode = UIViewContentModeScaleAspectFit;
background.frame = CGRectIntegral(background.frame);
[self.view addSubview:background];
4

2 回答 2

0

您可能会尝试在 UIImageView 图层上设置光栅化。

原因是,您选择的是原始图像,这取决于设备可能是 1000 像素。然后你使用方面拟合将其压扁。没有光栅化来平滑图像。

那是我的猜测。没有设备信息,您的问题很难回答。

于 2013-08-20T05:52:21.513 回答
0

设法弄清楚 - 我添加了两行:

UIImage *gotImage = [info objectForKey:UIImagePickerControllerOriginalImage];

float scale = (self.view.frame.size.width * [[UIScreen mainScreen] scale] )/imageToResize.size.width; //Changed line
imageToResize = [imageToResize resizedImage:CGSizeMake(scale * imageToResize.size.width, scale * imageToResize.size.height) interpolationQuality:kCGInterpolationHigh];

UIImage *testImage = [UIImage imageWithCGImage:blurredImage.CGImage scale:[[UIScreen mainScreen] scale] orientation:blurredImage.imageOrientation]; //Changed line
UIImageView *background = [[UIImageView alloc] initWithImage:testImage]; 

background.contentMode = UIViewContentModeScaleAspectFit;
background.frame = CGRectIntegral(background.frame);
[self.view addSubview:background];
于 2013-08-20T22:35:09.730 回答