I use this method to resize an image to the double of its original dimensions:
- (UIImage *)doubleSizeImage:(UIImage *)image {
CGSize newSize = CGSizeMake(image.size.width*2, image.size.height*2);
UIGraphicsBeginImageContext(newSize);
CGContextSetInterpolationQuality(UIGraphicsGetCurrentContext(), kCGInterpolationHigh);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
The fact is that the interpolation is still poor: I can see well the pixelated effect which, for example, iOS Safari doesn’t have when zooming pages. So I was wondering if there a better way to upscale an image, also using a third party library/category or something like that? Thanks!
Any time you interpolate, you’re going to get some kind of artifacts.
Safari doesn’t get artifacts on the page because the page is essentially a vector document, with outline fonts and resizable objects—but if you look at a raster image on the page, you’ll see that if you blow it up big enough, the image will indeed show artifacts. Safari is not immune; nothing is.