在我的應用程序中,我想要高品質的圖像。圖片從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