WDImagePicker icon indicating copy to clipboard operation
WDImagePicker copied to clipboard

Fix for incorrect crop for some images

Open vopt opened this issue 8 years ago • 0 comments

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
}

vopt avatar Jun 17 '16 16:06 vopt