-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I set applyMaskToCroppedImage = YES,but the returned image have margins and their alpha is 0. #182
Comments
Sorry, but I didn't understand your problem. Please provide more information. |
Try to set |
Not work.. |
Can you, please, provide your implementation of |
PS: self.shouldClipToCircle is false#pragma mark - RSKImageCropViewControllerDelegate
- (CGRect)imageCropViewControllerCustomMaskRect:(RSKImageCropViewController *)controller{
return [self getRect];
}
- (UIBezierPath *)imageCropViewControllerCustomMaskPath:(RSKImageCropViewController *)controller{
CGRect rect = [self getRect];
if (self.shouldClipToCircle) {
return [UIBezierPath bezierPathWithArcCenter:CGRectGetCenter(rect) radius:rect.size.width / 2.0 startAngle:0 endAngle:2*M_PI clockwise:YES];
}
return [UIBezierPath bezierPathWithRect:rect];
}
- (void)imageCropViewControllerDidCancelCrop:(RSKImageCropViewController *)controller{
[self.navigationController popViewControllerAnimated:YES];
}
-(void)imageCropViewController:(RSKImageCropViewController *)controller willCropImage:(UIImage *)originalImage{
// int controllerCount = (int)self.navigationController.viewControllers.count;
// [self.navigationController popToViewController:self.navigationController.viewControllers[controllerCount - 3] animated:YES];
}
- (void)imageCropViewController:(RSKImageCropViewController *)controller didCropImage:(UIImage *)croppedImage usingCropRect:(CGRect)cropRect{
if (_imagesCompletion) {
_imagesCompletion([NSArray arrayWithObject:croppedImage]);
}
[self.navigationController setNavigationBarHidden:NO animated:NO];
int controllerCount = (int)self.navigationController.viewControllers.count;
[self.navigationController popToViewController:self.navigationController.viewControllers[controllerCount - 3] animated:YES];
}
#pragma mark 辅助方法
- (CGRect)getRect{
//
if (self.imageSize.width == 0 || self.imageSize.height == 0) {
self.imageSize = CGSizeMake(kScreenWidth, kScreenWidth);
}
CGFloat scale = MIN(kScreenWidth / self.imageSize.width, kScreenHeight / self.imageSize.height);
CGSize scaleSize = CGSizeMake(scale * self.imageSize.width, scale * self.imageSize.height);
CGRect rect = CGRectMake(self.view.centerX - scaleSize.width / 2.0, self.view.centerY - scaleSize.height / 2.0, scaleSize.width, scaleSize.height);
return rect;
} |
@shenguanjiejie Please provide values for |
I mean |
I just checked the code and the image you provided and I can say that everything should work as you need if you set the value of |
Sorry about my bad English... You may not understand me. Here is my question with a demo. |
@shenguanjiejie Fixed in develop branch. Please check if it works for you. |
Perfect! Thanks😀 |
…hould always be equal to `size` of `cropRect`. #182
Eventually, it is fixed in 1.6.4 🎉 |
Then I call UIImageJPEGRepresentation(image,1); the margins will turn to whiteColor. like that
The text was updated successfully, but these errors were encountered: