title: iOS - CGImage cropping rotated rectangle
body: <p>I am using Vision framework to detect rectangles on images. When Vision detected any rectangle it returns four points of rectangle corners. I would like to crop this rectangle from cgImage but the main problem is how to do it when rectangle is rotated. Because in apple documentation (<a href="https://developer.apple.com/documentation/coregraphics/cgrect" rel="nofollow noreferrer">CGRect documentation</a> there is no way to get rectangle by his corners. So how can I crop this rect ?</p>
  <p><a href="https://i.stack.imgur.com/GwVTU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GwVTU.png" alt="Example of cgImage with detected rectangle" /></a></p>
  <p>I would like to crop only selected rectangle. So I would like to get something like this <a href="https://i.stack.imgur.com/fHKjj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fHKjj.png" alt="Expected result of cropping" /></a></p>
  <p>Is there any way to achieve this ?</p>