-
Notifications
You must be signed in to change notification settings - Fork 471
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
Image not moving in vertical mode after rotate. #179
Comments
@dineshmahajan Can you provide a sample project? |
Please check attach video file Frame is not updates after rotate |
@dineshmahajan I noticed that you are using a custom crop mode. |
Class.zip Thanks |
If you want to support the rotation when If the image is not rotated, then the movement rect coincides with the mask rect. In other cases you need to calculate and return the correct value from You can see how it is done for the square here. |
If i need to do calculation at my end. Then what is the use library in case
of custom crop. It should be managed by library. Please let me know if you
can provide me solution otherwise i will use other library.
…On Sun, Nov 5, 2017 at 2:53 PM, Ruslan Skorb ***@***.***> wrote:
Closed #179 <#179>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#179 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANcXdBXU7YXkCMzIfoe1x1aGnmjK4lgpks5szX5-gaJpZM4QRbi9>
.
|
It is impossible to calculate a movement rect for an unknown mask rect. Therefore, it is the responsibility of the developer who uses this library. |
Can you please provide me example code where you implemented custom crop
functionality. So i can test and implement accordingly.
…On Sun, Nov 5, 2017 at 3:47 PM, Ruslan Skorb ***@***.***> wrote:
It is impossible to calculate a movement rect for an unknown mask rect.
Therefore, it is the responsibility of the developer who uses this library.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#179 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANcXdNB62Q4e6ovtUJqgIM8p30ljR2jmks5szYtEgaJpZM4QRbi9>
.
|
You can see how to calculate a movement rect for the square here. I hope it will guide you in the right direction. |
I want to implement same like twitter. It will be great if you can send me with custom . Because in case of square it's easy to manage height and width. I need to implement this today.
… On 05-Nov-2017, at 3:56 PM, Ruslan Skorb ***@***.***> wrote:
You can see how to calculate a movement rect for the square here. I hope it will guide you in the right direction.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@ruslanskorb i also needed this implementation so maybe you can add the following code i used in the readme file: add this to your Utils class or VC Swift: func getBoundingRectAfterRotation(rect: CGRect, angle: Float) -> CGRect {
let newWidth = Float(rect.size.width) * abs(cosf(angle)) + Float(rect.size.height) * fabs(sinf(angle))
let newHeight = Float(rect.size.height) * fabs(cosf(angle)) + Float(rect.size.width) * fabs(sinf(angle))
let newX = Float(rect.origin.x) + ((Float(rect.size.width) - newWidth) / 2);
let newY = Float(rect.origin.y) + ((Float(rect.size.height) - newHeight) / 2);
let rotatedRect = CGRect(x: CGFloat(newX), y: CGFloat(newY), width: CGFloat(newWidth), height: CGFloat(newHeight))
return rotatedRect
} Objective-C: - (CGRect)getBoundingRectAfterRotation:(CGRect)rect angle:(float)angle {
CGFloat newWidth = (float)(rect.size.width) * fabs(cosf(angle)) + (float)(rect.size.height) * fabs(sinf(angle));
CGFloat newHeight = (float)(rect.size.height) * fabs(cosf(angle)) + (float)(rect.size.width) * fabs(sinf(angle));
CGFloat newX = (float)(rect.origin.x) + (((float)(rect.size.width) - newWidth) / 2);
CGFloat newY = (float)(rect.origin.y) + (((float)(rect.size.height) - newHeight) / 2);
CGRect rotatedRect = CGRectMake((float)(newX), (float)(newY), (float)(newWidth), (float)(newHeight));
return rotatedRect;
} then implement RSKImageCropViewControllerDataSource and add: func imageCropViewControllerCustomMovementRect(_ controller: RSKImageCropViewController) -> CGRect {
return self.getBoundingRectAfterRotation(rect: controller.maskRect, angle: Float(controller.rotationAngle))
} thank you for this great library! |
@iphonewsro Thanks! I'm thinking of adding a new mode |
Added working example to README. |
When I rotate image with 90 degree then not able to move image top & down, please check & let me know solution for it.
The text was updated successfully, but these errors were encountered: