Search code examples
androidandroid-imageview

How do I save the viewport bitmap of an imageview? - Android


I only want to save the bitmap of the image being displayed/cropped in the ImageView.

When I call this, it returns the entire bitmap:

Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();

Solution

  • Use this to get the bitmap from ImageView

    imageView.buildDrawingCache();
    Bitmap bmap = imageView.getDrawingCache();