imageView.getBackground(), is to get its background image;
When calling getDrawingCache, pay attention to the following two points:
-
Before calling the getDrawingCache() method to get the image from the ImageView object, be sure to call the setDrawingCacheEnabled(true) method:
imageview.setDrawingCacheEnabled(true);
Otherwise, the image cannot be obtained from the ImageView object iv_photo;
-
After calling the getDrawingCache() method to get the image from the ImageView object, be sure to call the setDrawingCacheEnabled(false) method:
imageview.setDrawingCacheEnabled(false);
To clear the drawing buffer, otherwise, the next image obtained from the ImageView object iv_photo is the original image.
-
mImageView.setDrawingCacheEnabled(true); Bitmap bitmap = Bitmap.createBitmap(mImageView.getDrawingCache()); mImageView.setDrawingCacheEnabled(false);