title: Implementation for custom image cropping in Android
body: <p>I need to implement the custom image cropping instead of using the system cropping (i.e. "com.android.camera.action.CROP"). I need to know the exact position of the cropping bounding box but this information is not retrievable if I choose to use the default cropping. Besides, the bitmap image is down sampled too much by default cropping. </p>
  
  <p>The steps are as following:</p>
  
  <ol>
  <li>Create the original size bitmap from source (using uri). The
  original size is about 4000x3000 which is too big.</li>
  <li>The user defines the crop area to extract the ROI which results in resizing of the original image to fit the ImageView. (size of ImageView is about 700x700)</li>
  <li>Record the position of the bounding box in the ImageView.</li>
  <li>Retrieve the cropped area from the original image and create another bitmap for it.</li>
  <li>Resize the cropped bitmap to fit the imageview size to show it on the screen.</li>
  </ol>
  
  <p>This approach works on my device (ZTE nuoio with Android 4.3) well. However, the app crashes on Samsung S4 with Android 4.4.4 and Note 4 while performing step 1 probably because of the out-of-memory error.</p>
  
  <p>Therefore, I try to do another approach that creates the bitmap which is down sampled from the source image, rather than having the original size bitmap image. </p>
  
  <p>I need to have the information of the exact position of cropped area from the original image. That is the reason why I didn't use default cropping. Could you please help me out with my case either providing</p>
  
  <ol>
  <li>the solutions to derive the exact coordinates of the bounding box of the cropped image in the original image as a matrix.</li>
  <li>how to solve the out-of-memory error in step 1 using the approach I mentioned above.</li>
  </ol>
  
  <p>Or other approach to achieve image cropping with knowing the exact coordinates of cropped area form the original image.</p>
  
  <p>Thank you so much. </p>