title: Crop the captured image on the basis of Rect Cordinates in android
body: <p>I am trying to crop out the portion inside the RoundRect. I have an overlay on top of PreviewView. The horizontal margin is 2% of the screen width and top is 15% of the screen height.</p>
  <p>When I take the picture, I want to crop it with the same proportion as the RoundRect displayed. As the resolution of the captured image is different than that of the screen, I am not being able to get the exact portion inside the rounded rectangle. Is there anyway I can use the margin value used for the RoundRect to get the margin value for the captured Image?</p>
  <p>I did try scaling it down to the screen size <a href="https://stackoverflow.com/a/60148392/5130133">as mentioned here</a> and crop it but even that doesn't help as quality and aspect ratio gets compromised.</p>
  <p>I am using bitmap to crop the captured image.</p>
  <pre><code>Bitmap.createBitmap(originalBp, left, top, right, bottom);
  </code></pre>
  <p><a href="https://i.stack.imgur.com/12Nzb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/12Nzb.jpg" alt=" " /></a></p>