GKImagePicker icon indicating copy to clipboard operation
GKImagePicker copied to clipboard

Example: Scaling on wrong axis

Open DanijelHuis opened this issue 11 years ago • 1 comments

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

DanijelHuis avatar Oct 29 '13 09:10 DanijelHuis

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

fleshgolem avatar Oct 29 '13 13:10 fleshgolem