UIImage cropping on user selected rectangle in iphone?
        Posted  
        
            by Rajendra Bhole
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Rajendra Bhole
        
        
        
        Published on 2010-05-03T10:24:37Z
        Indexed on 
            2010/05/03
            10:28 UTC
        
        
        Read the original article
        Hit count: 673
        
iphone
Hi, I developing an small application in which i want to crop the UIImage captured by imagePickerControllerSourceTypeOfCamera. The UIImage should crop by user selected crop area or cropped rectangle. That means first user capture the image from the camera.Then on captured image the user selected an rectangle having color gray.That image(image data) should crop from that gray colored rectangle. My under develop code is as follows.
-(IBAction) getPhoto:(id)sender
{
    UIImagePickerController* imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.delegate = self;
    if((UIButton *) sender == btnphotoAlbum)
    {
    imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }
    else
    {
        imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 
    }
    imagePickerController.allowsImageEditing = YES;
    //imagePickerController.toolbar.barStyle =UIBarStyleBlackOpaque;
    //UIToolbar *toolBar=[[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 20, 320)]; 
    //imagePickerController. 
    [self presentModalViewController:imagePickerController animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { UIImage *selectedImage = image; UIImage *originalImage = [editingInfo objectForKey:@"UIImagePickerControllerOriginalImage"]; NSValue *cropRect = [editingInfo objectForKey:UIImagePickerControllerCropRect]; CGRect theRect = [cropRect CGRectValue]; - //captureImage.image =[info objectForKey:@"UIImagePickerControllerOriginalImage"]; [picker dismissModalViewControllerAnimated:YES]; } 
How i crop the image?
© Stack Overflow or respective owner