How to grab an enlarged UIImageView inside Scrollview for cropping in Android?

I added this link. How do I get an enlarged UIImageView inside the scroll bar for cropping?

I want to do the same in android as shown in the screenshots below. How can i do this?

step 1

enter image description here

enter image description here

+3
source share
1 answer

func getZoomedImage () → UIImage {

    //Calculate the required area from the scrollview
    var visibleRect = CGRect()
    let scale: CGFloat = CGFloat(1.0 / scrollViewGallery.zoomScale)
    visibleRect.origin.x = scrollViewGallery.contentOffset.x * scale
    visibleRect.origin.y = scrollViewGallery.contentOffset.y * scale
    visibleRect.size.width = scrollViewGallery.bounds.size.width * scale
    visibleRect.size.height = scrollViewGallery.bounds.size.height * scale
    let cgImg: CGImage? = imgView.image?.cgImage?.cropping(to: visibleRect)
    let croppedImg = UIImage(cgImage: cgImg!)
    return croppedImg
}
0
source

All Articles