Coder Social home page Coder Social logo

Comments (17)

yangqingren avatar yangqingren commented on June 12, 2024 2

nice, this problem has been solved in the dev.

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

Hi @yangqingren,

I can't reproduce your issue. Could you provide a test project?

Thanks!

from rskimagecropper.

yangqingren avatar yangqingren commented on June 12, 2024

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.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

@yangqingren How do you rotate an image? Programmatically or with a gesture?

from rskimagecropper.

yangqingren avatar yangqingren commented on June 12, 2024

with a gesture

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

@yangqingren Could you record a video of what exactly is wrong?

from rskimagecropper.

yangqingren avatar yangqingren commented on June 12, 2024

have been sent ‘[email protected]

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

@yangqingren Thanks! Now I noticed the problem.

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

RPReplay_Final1563800730.MP4.zip

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

Hi @yangqingren,

I pushed the fix in develop branch. Could you test it?

from rskimagecropper.

yangqingren avatar yangqingren commented on June 12, 2024

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.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

@yangqingren Did you test develop branch?

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

@yangqingren This is what I see - RPReplay_Final1563886346.MP4.zip

from rskimagecropper.

yangqingren avatar yangqingren commented on June 12, 2024

You try clicking the choose button.

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

Hi @yangqingren! Could you check the latest changes in the develop branch?

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

@yangqingren Glad to hear it!

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on June 12, 2024

@yangqingren Fixed in 2.2.3 🚀 Thank you for reporting!

from rskimagecropper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.