I am googling from last few hour and get solution for crop an Image, But I am confused and wants to know what is the difference between these two?
Problem : I wants to crop a rectangle image from inside an Image, I already detected the boundary.
First :
CGRect rect = CGRectMake(0,0,320, 460);
// Create bitmap image from original image data,
// using rectangle to specify desired crop area
CGImageRef imageRef = CGImageCreateWithImageInRect([imageView.image CGImage], rect);
UIImage *imgs = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
Second :
CGRect rect = [backView bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[backView.layer renderInContext:context];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();