开发者

How to reduce the crop image box size in iphone?

开发者 https://www.devze.com 2022-12-28 11:40 出处:网络
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 perfec

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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消