在我的应用程序中,我想要高品质的图像。图片从Facebook好友列表中加载。当图像以较小尺寸(50 * 50)加载时,其质量很好。但是,当我尝试以更大尺寸(280 * 280)获得该图像时,图像质量下降。iPhone中的高品质圆角图像
对于圆角在做这样的:
self.mImageView.layer.cornerRadius = 10.0;
self.mImageView.layer.borderColor = [UIColor blackColor].CGColor;
self.mImageView.layer.borderWidth = 1.0;
self.mImageView.layer.masksToBounds = YES;
对于使用下面的代码获取图像M:
self.mImageView.image = [self imageWithImage:profileImage scaledToSize:CGSizeMake(280, 280)];
- (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize {
UIGraphicsBeginImageContextWithOptions(newSize, YES,0.0);
CGContextRef context = CGContextRetain(UIGraphicsGetCurrentContext());
CGContextTranslateCTM(context, 0.0, newSize.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextSetInterpolationQuality(context, kCGInterpolationLow);
CGContextSetAllowsAntialiasing (context, TRUE);
CGContextSetShouldAntialias(context, TRUE);
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, newSize.width, newSize.height),image.CGImage);
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
我检查我的代码几次,但无法弄清楚如何使图像完美。那么,大家如何提高图像质量呢? Thanx提前...
所以CSI一直在骗我? – jrturton
@jrturton“CSI”? – justin
@justin,我已经根据你的建议改变了我的代码,即使现在图像正在模糊..任何想法,如果我错过了什么? – iCoder4777