title: Android: Unable to cut out the overlay image and the photo within the overlay
body: <p>I have the following code where you can combine the photo data and the overlay image as
  one bitmap then save it. The problem is that I dont know how to cropout only the overlay image
  and the photo image within the overlay image. I dont want to save the preview image outside of the overlay image.
  It would be great if you can help me out with a sample or tips! I would love to hear from you! </p>
  
  <p>I want to merge the data of the callback with the mOverlayLayout, its a RelativeLayout with a ImageView of a 
  costume where you can place your face. </p>
  
  <pre><code>jpegCallback = (byte[] data, Camera camera) -&gt; {
              Bitmap tmp_bitmap = BitmapFactory.decodeByteArray (data, 0, data.length);
  
              int width = tmp_bitmap.getWidth ();
              int height = tmp_bitmap.getHeight ();
              Matrix matrix = new Matrix ();
              int angleToRotate = CameraUtil.getRoatationAngle(CameraMainActivity.this,
                      Camera.CameraInfo.CAMERA_FACING_BACK);
              angleToRotate = angleToRotate + mPortrait;
              matrix.postRotate (angleToRotate);
              Bitmap bitmap = Bitmap.createBitmap (tmp_bitmap, 0, 0, width, height, matrix, true);
              Bitmap baseBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
  
              mOverlayLayout.setDrawingCacheEnabled(true);
              mOverlayLayout.buildDrawingCache();
              Bitmap overlay = Bitmap.createBitmap(mOverlayLayout.getDrawingCache());
              mOverlayLayout.setDrawingCacheEnabled(false);
  
  
              Bitmap mergedImage = mCameraUtil.combineImages(overlay, baseBitmap);
  </code></pre>
  
  <p>// This is the method to combine the images </p>
  
  <pre><code>            public Bitmap combineImages(Bitmap frame, Bitmap image) {
          //Base frame source
          Rect src = new Rect(0,0, frame.getWidth(), frame.getHeight());
          RectF dst = new RectF(0, 0, image.getWidth(), image.getHeight());
          Paint paint = new Paint();
          Canvas comboImage = new Canvas(image);
  
          comboImage.drawBitmap(frame, src, dst, paint);
          Runtime.getRuntime().gc();
          return image;
  }
  </code></pre>
  
  <p>//For example how will I crop out only the imageview overlay and the photo data within the overlay? </p>
  
  <p>[sample image<a href="https://i.stack.imgur.com/seqQl.jpg" rel="nofollow noreferrer">1</a></p>