Get Bitmap in imageview

imageView.getBackground(), is to get its background image;

When calling getDrawingCache, pay attention to the following two points:

  1. 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;

  2. 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.

  3. mImageView.setDrawingCacheEnabled(true);
    Bitmap bitmap = Bitmap.createBitmap(mImageView.getDrawingCache());
    mImageView.setDrawingCacheEnabled(false);

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326617948&siteId=291194637