Comments (17)
nice, this problem has been solved in the dev.
from rskimagecropper.
Hi @yangqingren,
I can't reproduce your issue. Could you provide a test project?
Thanks!
from rskimagecropper.
Using your example, CGSizeMake (16.0f, 9.0f) (not square),
Rotate and drag down to the bottom;
Should be reproducible.(If it weren't for the problems I caused)
I will solve this problem temporarily by :
-(CGRect)cropRect
{
CGRect maskRect = self.maskRect;
CGFloat rotationAngle = self.rotationAngle;
CGRect rotatedImageScrollViewFrame = self.imageScrollView.frame;
float zoomScale = 1.0 / self.imageScrollView.zoomScale;
UIScrollView *scrollView = [[UIScrollView alloc] init];
scrollView.frame = self.imageScrollView.frame;
scrollView.contentSize = self.imageScrollView.contentSize;
scrollView.contentOffset = self.imageScrollView.contentOffset;
scrollView.transform = CGAffineTransformIdentity;
CGRect imageScrollViewFrame = scrollView.frame;
scrollView.frame = self.maskRect;
...
...
...
// self.imageScrollView.transform = imageScrollViewTransform;
// self.imageScrollView.frame = imageScrollViewFrame;
with a new object to calculate ‘ cropRect’
from rskimagecropper.
@yangqingren How do you rotate an image? Programmatically or with a gesture?
from rskimagecropper.
with a gesture
from rskimagecropper.
@yangqingren Could you record a video of what exactly is wrong?
from rskimagecropper.
have been sent ‘[email protected] ’
from rskimagecropper.
@yangqingren Thanks! Now I noticed the problem.
from rskimagecropper.
RPReplay_Final1563800730.MP4.zip
from rskimagecropper.
Hi @yangqingren,
I pushed the fix in develop branch. Could you test it?
from rskimagecropper.
The same problem has arisen by the branch #213
You can test this way:
- (void)onAddPhotoButtonTouch:(UIButton *)sender
{
UIImage *photo = [UIImage imageNamed:@"photo"];
RSKImageCropViewController *imageCropVC = [[RSKImageCropViewController alloc] initWithImage:photo cropMode:RSKImageCropModeCustom];
imageCropVC.dataSource = self;
imageCropVC.delegate = self;
imageCropVC.rotationEnabled = YES;
[self.navigationController pushViewController:imageCropVC animated:YES];
}
// Returns a custom rect for the mask.
- (CGRect)imageCropViewControllerCustomMaskRect:(RSKImageCropViewController *)controller
{
CGSize aspectRatio = CGSizeMake(16.0f, 9.0f);
CGFloat viewWidth = CGRectGetWidth(controller.view.frame);
CGFloat viewHeight = CGRectGetHeight(controller.view.frame);
CGFloat maskWidth;
if ([controller isPortraitInterfaceOrientation]) {
maskWidth = viewWidth;
} else {
maskWidth = viewHeight;
}
CGFloat maskHeight;
do {
maskHeight = maskWidth * aspectRatio.height / aspectRatio.width;
maskWidth -= 1.0f;
} while (maskHeight != floor(maskHeight));
maskWidth += 1.0f;
CGSize maskSize = CGSizeMake(maskWidth, maskHeight);
CGRect maskRect = CGRectMake((viewWidth - maskSize.width) * 0.5f,
(viewHeight - maskSize.height) * 0.5f,
maskSize.width,
maskSize.height);
return maskRect;
}
// Returns a custom path for the mask.
- (UIBezierPath *)imageCropViewControllerCustomMaskPath:(RSKImageCropViewController *)controller
{
CGRect rect = controller.maskRect;
CGPoint point1 = CGPointMake(CGRectGetMinX(rect), CGRectGetMaxY(rect));
CGPoint point2 = CGPointMake(CGRectGetMaxX(rect), CGRectGetMaxY(rect));
CGPoint point3 = CGPointMake(CGRectGetMaxX(rect), CGRectGetMinY(rect));
CGPoint point4 = CGPointMake(CGRectGetMinX(rect), CGRectGetMinY(rect));
UIBezierPath *rectangle = [UIBezierPath bezierPath];
[rectangle moveToPoint:point1];
[rectangle addLineToPoint:point2];
[rectangle addLineToPoint:point3];
[rectangle addLineToPoint:point4];
[rectangle closePath];
return rectangle;
}
// Returns a custom rect in which the image can be moved.
- (CGRect)imageCropViewControllerCustomMovementRect:(RSKImageCropViewController *)controller
{
if (controller.rotationAngle == 0) {
return controller.maskRect;
} else {
CGRect maskRect = controller.maskRect;
CGFloat rotationAngle = controller.rotationAngle;
CGRect movementRect = CGRectZero;
movementRect.size.width = CGRectGetWidth(maskRect) * fabs(cos(rotationAngle)) + CGRectGetHeight(maskRect) * fabs(sin(rotationAngle));
movementRect.size.height = CGRectGetHeight(maskRect) * fabs(cos(rotationAngle)) + CGRectGetWidth(maskRect) * fabs(sin(rotationAngle));
movementRect.origin.x = CGRectGetMinX(maskRect) + (CGRectGetWidth(maskRect) - CGRectGetWidth(movementRect)) * 0.5f;
movementRect.origin.y = CGRectGetMinY(maskRect) + (CGRectGetHeight(maskRect) - CGRectGetHeight(movementRect)) * 0.5f;
movementRect.origin.x = floor(CGRectGetMinX(movementRect));
movementRect.origin.y = floor(CGRectGetMinY(movementRect));
movementRect = CGRectIntegral(movementRect);
return movementRect;
}
}
from rskimagecropper.
@yangqingren Did you test develop branch?
from rskimagecropper.
@yangqingren This is what I see - RPReplay_Final1563886346.MP4.zip
from rskimagecropper.
You try clicking the choose button.
from rskimagecropper.
Hi @yangqingren! Could you check the latest changes in the develop branch?
from rskimagecropper.
@yangqingren Glad to hear it!
from rskimagecropper.
@yangqingren Fixed in 2.2.3 🚀 Thank you for reporting!
from rskimagecropper.
Related Issues (20)
- 'Use of undeclared identifier '__tg_promote1'' error in Objective-C++ project HOT 22
- How can we draw and extract a part of image? HOT 2
- App crash for Live Photos on iOS HOT 1
- Resize the image smaller within the crop area HOT 1
- Issue in zoom out HOT 3
- How can one manipulate maskLayerColor in Swift? HOT 5
- 可以开放 缩放的最小比例的api吗 HOT 3
- What is the point of method swizzling UIApplication.shared? HOT 1
- Support for SPM HOT 2
- Localisation is not working HOT 2
- The position of the photo to be cropped does not change. HOT 2
- Warning when include RSKImageCropper in SPM HOT 2
- Prevent user from cropping a photo with edges outside of the image boundary HOT 5
- Circlemask center, width etc. + Cancel button completion boolean? HOT 1
- Small and fix size cropping HOT 4
- Able to push select button when dragging HOT 1
- RSKImageCropper HOT 3
- Warning related to UI-related operation on a background thread HOT 2
- Privacy manifest required by Apple HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rskimagecropper.