Image blurred slightly when drawing in drawRect (Swift)
<p>I am building a circle crop function in Swift. I pretty much have everything working however when I save the cropped photo it is slightly blurry:</p>

<p><a href="https://i.stack.imgur.com/3uGUE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3uGUE.png" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/dYysK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dYysK.jpg" alt="enter image description here"></a></p>

<p>Not sure if it is visible here or not but on my iPhone I can see a difference, slight blurring. I'm not zooming in more than the actual size of the image. I am using a UIScrollView with max zoom factor set to 1.0. The crop code is:</p>

<pre><code>  func didTapOk() {

    let scale = scrollView.zoomScale
    let newSize = CGSize(width: image!.size.width*scale, height: image!.size.height*scale)
    let offset = scrollView.contentOffset

    UIGraphicsBeginImageContext(CGSize(width: 240, height: 240))
    let circlePath = UIBezierPath(ovalInRect: CGRect(x: 0, y: 0, width: 240, height: 240))
    circlePath.addClip()
    var sharpRect = CGRect(x: -offset.x, y: -offset.y, width: newSize.width, height: newSize.height)
    sharpRect = CGRectIntegral(sharpRect)

    image?.drawInRect(sharpRect)
    let finalImage = UIGraphicsGetImageFromCurrentImageContext()
    UIImageWriteToSavedPhotosAlbum(finalImage, nil, nil, nil)

}
</code></pre>

<p>Here I am trying to use <code>CGRectIntegral</code> to improve the result but it doesn't seem to make any difference. Any pointers on what I could do to improve this? </p>