手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >android将Bitmap对象保存到SD卡中的方法
android将Bitmap对象保存到SD卡中的方法
摘要:本文实例讲述了android将Bitmap对象保存到SD卡中的方法。分享给大家供大家参考。具体如下:BitmaplogoBitmap=Bit...

本文实例讲述了android将Bitmap对象保存到SD卡中的方法。分享给大家供大家参考。具体如下:

Bitmap logoBitmap = BitmapFactory.decodeResource(mcontext.getResources(), R.drawable.arcnote_logo); ByteArrayOutputStream logoStream = new ByteArrayOutputStream(); boolean res = logoBitmap.compress(Bitmap.CompressFormat.PNG,100,logoStream); //将图像读取到logoStream中 byte[] logoBuf = logoStream.toByteArray(); //将图像保存到byte[]中 Bitmap temp = BitmapFactory.decodeByteArray(logoBuf,0,logoBuf.length); //将图像从byte[]中读取生成Bitmap 对象 temp saveMyBitmap("tttt",temp); //将图像保存到SD卡中 public void saveMyBitmap(String bitName,Bitmap mBitmap){ File f = new File("/sdcard/" + bitName + ".png"); try { f.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block } FileOutputStream fOut = null; try { fOut = new FileOutputStream(f); } catch (Exception e) { e.printStackTrace(); } mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); try { fOut.flush(); } catch (IOException e) { e.printStackTrace(); } try { fOut.close(); } catch (IOException e) { e.printStackTrace(); } }

希望本文所述对大家的Android程序设计有所帮助。

【android将Bitmap对象保存到SD卡中的方法】相关文章:

android中添加按钮事件的方法

将文件放到Android模拟器的SD卡中的两种解决方法

Android 用SQLite实现事务的方法

Android 九宫格的实现方法

Android RadioButton单选框的使用方法

android开发中获取手机分辨率大小的方法

android帮助文档打开慢的三种解决方法

Android实现图片循环播放的实例方法

Android中实现EditText圆角的方法

android图像绘制(一)多种方法做图像镜像

精品推荐
分类导航