title: Android Custom shape image crop
body: <p>I want to crop the image in different shapes for that I write the XML code for that as below.                </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;               
  
  &lt;RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"&gt;
  
        &lt;RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/relative"&gt;
  
            &lt;ImageView
                   android:layout_width="match_parent"
                   android:layout_height="450dp"
                   android:id="@+id/original"
                   android:src="@drawable/image1"/&gt;
  
  
            &lt;ImageView
                   android:layout_width="match_parent"
                   android:layout_height="450dp"
                   android:id="@+id/frame"
                   android:scaleType="matrix"
                   android:src="@drawable/f1" /&gt;
  
       &lt;/RelativeLayout&gt;
  
         &lt;Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/btnblur"
            android:layout_marginTop="450dp"
            android:text="Crop"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and the layout is as shown below <a href="https://i.stack.imgur.com/PdzIj.png" rel="nofollow noreferrer">output of this layout</a></p>
  
  <p>And in the button click method, I wrote the code as below</p>
  
  <p>Bitmap output = getBitmapOfView(frame_img);  [here frame_img is the view contains the shape]</p>
  
  <p>but am getting the output as
  <a href="https://i.stack.imgur.com/wDoJ2.png" rel="nofollow noreferrer">output on button click</a></p>
  
  <p>so how to get the image inside the defined shape. </p>