Android从imageview中获得bitmap

第一种:

使用setDrawingCacheEnabled()和getDrawingCache()这两种方法,第一个是为了设置是否开启缓存,第二个就可以直接获得imageview中的缓存,一般来说需要在获得缓存以后setDrawingCacheEnabled设置为false,因为这样才能让之前的缓存去掉,不会影响后来新的缓存。 

image.setDrawingCacheEnabled(true);    

Bitmap bm = image.getDrawingCache();

image.setDrawableCacheEnabled(false);

第二种: 

 
Bitmap bm =((BitmapDrawable) ((ImageView) image).getDrawable()).getBitmap();  

直接强行获得内部的图片。

原文地址:https://www.cnblogs.com/diyishijian/p/5899010.html