Skip to content
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

Example: Scaling on wrong axis #37

Open
DanijelHuis opened this issue Oct 29, 2013 · 1 comment
Open

Example: Scaling on wrong axis #37

DanijelHuis opened this issue Oct 29, 2013 · 1 comment

Comments

@DanijelHuis
Copy link

Hi, i noticed in some cases scaling is wrong. Example(resizeableCropArea=NO):
Image size: 200x100
Crop size: 120x110

I also noticed that it works OK when resizableCropArea=YES due to different scaling calculation. Using this seems to solve all problems for me, including square images, tested on 20+ images:

-(CGRect)_calcVisibleRectForCropArea
{
    CGFloat scale = self.imageView.image.size.width / self.imageView.frame.size.width;
    scale *= self.scrollView.zoomScale;

    //extract visible rect from scrollview and scale it
    CGRect visibleRect = [scrollView convertRect:scrollView.bounds toView:imageView];
    visibleRect = GKScaleRect(visibleRect, scale);

    return visibleRect;
}

Note: I always set images to normal orientation before passing them to GKImageCropViewController, otherwise it doesn't work.
BTW: Navigation bar sometimes disappears :P

@fleshgolem
Copy link

Nice timing, I discovered the same problem some moments ago. Gonna submit a pull request for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants