title: Masking an image using bezierpath with image's full resolution
body: <p><a href="https://i.stack.imgur.com/fqIEa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fqIEa.jpg" alt="enter image description here"></a>
  Hi, I have a path (shape) and a high-resolution image. I make the high res image to be AspectFit inside the view on which I draw the path and I want to mask the image with the path but at the full resolution of the image, not at the resolution in which we see the path. The problem, It works perfectly when I don't upscale them up for high-resolution masking but when I do, everything is messed up. The mask gets stretched and the origins don't make sense.</p>
  
  <p><a href="https://i.stack.imgur.com/ZwddD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZwddD.jpg" alt="enter image description here"></a></p>
  
  <p>All I want is to be able to upscale the path with the same aspect ratio of the image (at the full resolution of the image) and position it correctly so It can mask the high res image properly.
  I've tried this:</p>
  
  <p><a href="https://stackoverflow.com/questions/9502737/masking-cgcontext-with-a-cgpathref">Masking CGContext with a CGPathRef?</a></p>
  
  <p>and this </p>
  
  <p><a href="https://stackoverflow.com/questions/633051/creating-mask-with-cgimagemaskcreate-is-all-black-iphone">Creating mask with CGImageMaskCreate is all black (iphone)</a></p>
  
  <p>and this </p>
  
  <p><a href="https://stackoverflow.com/questions/40815247/clip-uiimage-to-uibezierpath-not-masking">Clip UIImage to UIBezierPath (not masking)</a></p>
  
  <p>none of which works correctly when I try to mask a high quality image (bigger than screen resolution)</p>
  
  <p><strong>EDIT</strong> I posted a working project to show the problem between normal quality masking (at screen's resolution) and high quality masking (at image's resolution) on github. I'd really appreciate any help. 
  <strong><a href="https://github.com/Reza-Abdolahi/HighResMasking" rel="nofollow noreferrer">https://github.com/Reza-Abdolahi/HighResMasking</a></strong></p>