title: Crop rectangle from image issue
body: <p>I need to take picture from camera in landscape orientation (capture the full screen) with this mask:</p>
  
  <p><a href="https://i.stack.imgur.com/kTrtP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kTrtP.png" alt="enter image description here"></a></p>
  
  <p>Then crop rectangle from image like this:
  <a href="https://i.stack.imgur.com/D6izA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D6izA.png" alt="enter image description here"></a></p>
  
  <p>I have some problem with cropping.
  I do(android):</p>
  
  <pre><code>public Bitmap getCropImage() {
  
      Bitmap bitmap = getBitmap();
      int captureBitmapWidth = bitmap.getWidth();
      int captureBitmapHeight = bitmap.getHeight();
  
      // to get a multiplicative factor of axises.
      float xCoefficient = captureBitmapWidth / 720.0;
      float yCoefficient = captureBitmapHeight / 480.0;
  
      int cropRectangleWidth = 200;
      int cropRectangleHeight = 100;
      int cropRectangle_a_x = 200;
      int cropRectangle_a_y = 300;
  
      bitmap = Bitmap.createBitmap(bitmap,
              Math.round(cropRectangle_a_x * xCoefficient),
              Math.round(cropRectangle_a_y * yCoefficient),
              Math.round(cropRectangleWidth * xCoefficient),
              Math.round(cropRectangleHeight * yCoefficient));
  
      return bitmap;
  }
  </code></pre>
  
  <p>iphone: </p>
  
  <pre><code>extension UIImage {
      func crop() -&gt; UIImage {
  
          // to get a multiplicative factor of axises.
          let xCoefficient : CGFloat = self.size.width / RectangleConfig.WIDTH;
          let yCoefficient : CGFloat = self.size.height / RectangleConfig.HEIGTH;
  
          var cropRect = CGRectMake(RectangleConfig.x * xCoefficient,
                                    RectangleConfig.y * yCoefficient,
                                    RectangleConfig.cropRectWidth * xCoefficient,
                                    RectangleConfig.cropRectHeight * yCoefficient)
  
          cropRect.origin.x *= self.scale
          cropRect.origin.y *= self.scale
          cropRect.size.width *= self.scale
          cropRect.size.height *= self.scale
  
          let imageRef = CGImageCreateWithImageInRect(self.CGImage, cropRect)
          let image = UIImage(CGImage: imageRef!, scale: self.scale, orientation: self.imageOrientation)
  
          return image
      }
  }
  </code></pre>
  
  <p>On some mobile devices, I get the correct result, on other the crop rectangle shifted down and to the left. Where is the mistake?</p>