手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >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开机自启动服务的实现方法

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

Android中实现EditText圆角的方法

Android 的Bitmap的修改方法

Android生存指南之:开发中的注意事项

android弹出activity设置大小的方法

Android中 动态改变对话框值的方法

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

Android 九宫格的实现方法

精品推荐
分类导航