将View转换成Bitmap
2014-07-14 11:28
190 查看
/** * 将中间的View保转换成Bitmap * */ private Bitmap saveViewBitmap(View view) { // get current view bitmap view.setDrawingCacheEnabled(true); view.buildDrawingCache(true); Bitmap bitmap = view.getDrawingCache(true); Bitmap bmp = duplicateBitmap(bitmap); if (bitmap != null && !bitmap.isRecycled()) { bitmap.recycle(); bitmap = null; } // clear the cache view.setDrawingCacheEnabled(false); return bmp; } public static Bitmap duplicateBitmap(Bitmap bmpSrc) { if (null == bmpSrc) { return null; } int bmpSrcWidth = bmpSrc.getWidth(); int bmpSrcHeight = bmpSrc.getHeight(); Bitmap bmpDest = Bitmap.createBitmap(bmpSrcWidth, bmpSrcHeight, Config.ARGB_8888); if (null != bmpDest) { Canvas canvas = new Canvas(bmpDest); final Rect rect = new Rect(0, 0, bmpSrcWidth, bmpSrcHeight); canvas.drawBitmap(bmpSrc, rect, rect, null); } return bmpDest; }
相关文章推荐
- Android把view的画面转换为bitmap (截屏)
- [转] Android把view的画面转换为bitmap
- 将View 转换成 Bitmap
- 将View转换成Bitmap
- Android中View转换为Bitmap及getDrawingCache=null的解决方法
- camera源码遗留bug;开启新任务;view转换为bitmap; 学习笔记
- Android中View转换为Bitmap及getDrawingCache=null的解决方法
- Android之View转换为Bitmap及getDrawingCache=null的解决方法
- Android中View转换为Bitmap!!!!!!!
- 将View转换成Bitmap的方法,可直接调用
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byte
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byt
- Android中View转换为Bitmap及getDrawingCache=null的解决方法
- Android之View转换为Bitmap及getDrawingCache=null的解决方法
- Android中View转换为Bitmap及getDrawingCache=null的解决方法
- Android把view的画面转换为bitmap
- Android中View转换为Bitmap及getDrawingCache=null的解决方法
- Android中View转换为Bitmap!!!!!!!
- 如何把View转换成Bitmap
- Android中View转换为Bitmap及getDrawingCache=null的解决方法