How to reduce the crop image box size in iphone?
In my application I m using UIImagePickerControllerCropRect to crop the image but I want to reduce the size of that cropping box of iphone which comes automatically so that my image crop to its perfect size which I want. I'm using the foll开发者_JAVA技巧owing code for that:
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
picker.allowsImageEditing = YES;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[picker dismissModalViewControllerAnimated:YES];
imageView.image = image;
CGSize size = [imageView.image size];
CGRect cropRect = CGRectMake(0.0, 0.0, size.width, size.height);
NSLog(@"Original image size = (%f, %f)", size.width, size.height);
NSValue *cropRectValue = [editingInfo objectForKey:@"UIImagePickerControllerCropRect"];
cropRect = [cropRectValue CGRectValue];
UIImageWriteToSavedPhotosAlbum(imageView.image, self, nil, nil);
}
精彩评论