Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Fix for incorrect crop for some images #5

Open
vopt opened this issue Jun 17, 2016 · 0 comments
Open

Fix for incorrect crop for some images #5

vopt opened this issue Jun 17, 2016 · 0 comments

Comments

@vopt
Copy link

vopt commented Jun 17, 2016

There's a bug that got ported from GKImagePicker. I'm not up to speed on the proper use of github so I'll just leave this here. Replace this function in WDImageCropView:

private func calcVisibleRectForResizeableCropArea() -> CGRect {
    let resizableView = cropOverlayView as! WDResizableCropOverlayView

    // first of all, get the size scale by taking a look at the real image dimensions. Here it 
    // doesn't matter if you take the width or the height of the image, because it will always
    // be scaled in the exact same proportion of the real image
    var sizeScale = self.imageView.image!.size.width / self.imageView.frame.size.width
    sizeScale *= self.scrollView.zoomScale

    // then get the position of the cropping rect inside the image
    var visibleRect = resizableView.contentView.convertRect(resizableView.contentView.bounds,
        toView: imageView)
    visibleRect = WDImageCropView.scaleRect(visibleRect, scale: sizeScale)

    return visibleRect
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant