Often the images cropped from other images in iPhone SDK are degraded in quality. This is because we take a snapshot of the original image (of the desired area). But the below mentioned code prevents from happening the above mentioned issue. The below mentioned code first upgrades quality of the image multiple times before cropping it (here the quality is upgraded to 4 times).
UIGraphicsBeginImageContextWithOptions(cropRect.frame.size, view.opaque, 4.0);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextConcatCTM(c, CGAffineTransformMakeTranslation(-cropRect.frame.origin.x, -cropRect.frame.origin.y));
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
0 Comment(s)