The following code will do the trick :
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
UIImage *image; // Creating the UIImage object UIGraphicsBeginImageContextWithOptions(destnRect.size, NO, 0.0); // Here destnRect is the desired rectangle for the output image and 0.0 value for scale means "correct scale for device's screen". CGImageRef sourceImage = CGImageCreateWithImageInRect([self CGImage], sourceRect); // Here sourceRect is the rectangle region for cropping and it happens here. image = [UIImage imageWithCGImage:sourceImg scale:0.0 orientation:self.imageOrientation]; // creating cropped UIImage. [image drawInRect:destRect]; // the actual scaling happens here, and orientation is taken care of automatically. CGImageRelease(sourceImage); image = UIGraphicsGetImageFromCurrentImageContext(); // Now "image" will contain the final cropped image UIGraphicsEndImageContext(); |
Incoming search terms:
- crop image edge xcode
- xcode crop image
- create uiimage programmatically xcode -view
- xcode ios crop uiimage
- xcode crop image programmatically
- xcode account for offset when cropping image
- ios xcode resize uiimage programmatically
- ios programmatically crop image
- how to crystallize image programmatically in xcode
- how to crop selected image programmatically in ios



