title: How to get bitmap of a view?
body: <p>Ok, so I'll try my best to explain my problem.
  I have used this code to get a "screenshot" of my FrameLayout</p>
  
  <pre><code>/**
   * Function that takes a screenshot of the view passed and returns a bitmap for it.
   *
   * @param view {@link View}
   * @return screenshot of the view passed
   */
  public Bitmap screenShot(View view) {
      Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),
              view.getHeight(), Bitmap.Config.ARGB_8888);
      Canvas canvas = new Canvas(bitmap);
      view.draw(canvas);
      return bitmap;
  }
  </code></pre>
  
  <p>Here is my FrameLayout</p>
  
  <pre><code>&lt;FrameLayout
      android:id="@+id/frame_layout_picture"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"&gt;
  
      &lt;ImageView
          android:id="@+id/photoImageView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:scaleType="fitCenter" /&gt;
  
      &lt;com.my.android.util.DrawCustomView
          android:id="@+id/draw_custom_view"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p><code>DrawCustomView</code> is used to paint on <code>photoImageView</code>.</p>
  
  <p>Now I also have different activity to crop image. So, I saved this bitmap (using <code>screenshot(view)</code>) in a file and send the file path to this crop activity. In my crop activity I am using <a href="https://github.com/ArthurHub/Android-Image-Cropper" rel="nofollow noreferrer">https://github.com/ArthurHub/Android-Image-Cropper</a> library's <code>CropImageView</code> to crop the image.
  When I try to crop the painted photo sent to crop activity I get a weird crop, something like this :</p>
  
  <p>The image doubles on cropping too much :
  <a href="https://drive.google.com/open?id=0B4jK5QX65b0ZSHdMTWIzZXluZXc" rel="nofollow noreferrer">https://drive.google.com/open?id=0B4jK5QX65b0ZSHdMTWIzZXluZXc</a></p>
  
  <p>Before zooming in :
  <a href="https://drive.google.com/open?id=0B4jK5QX65b0ZeUk3NUlGUHRSQ0E" rel="nofollow noreferrer">https://drive.google.com/open?id=0B4jK5QX65b0ZeUk3NUlGUHRSQ0E</a></p>
  
  <p>This is how a normal picture appears in crop activity :
  <a href="https://drive.google.com/open?id=0B4jK5QX65b0ZNk9oSG1ZaGxYOVk" rel="nofollow noreferrer">https://drive.google.com/open?id=0B4jK5QX65b0ZNk9oSG1ZaGxYOVk</a></p>
  
  <p>I also notice that the bounds for cropping are restricted to image size in the normal case but when edited using screenshot(), the bounds take the size of the screen.</p>
  
  <p>I have tested my crop activity beforehand and it works fine for images sent from camera.
  I also tried to send a picture that is not obtained using screenshot function, and it worked fine in crop activity.</p>
  
  <p>I'll be happy to provide more info, any help is much appreciated... I am relatively new to android development :)</p>
  
  <p>EDIT</p>
  
  <p>This video might give more perspective to the problem
  <a href="https://drive.google.com/open?id=0B4jK5QX65b0ZSUVFZDlQeTc4QnM" rel="nofollow noreferrer">https://drive.google.com/open?id=0B4jK5QX65b0ZSUVFZDlQeTc4QnM</a></p>