欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android將Bitmap對(duì)象保存到SD卡中的方法

 更新時(shí)間:2015年04月23日 15:20:22   作者:滄海一粟……  
這篇文章主要介紹了android將Bitmap對(duì)象保存到SD卡中的方法,涉及Android讀寫(xiě)SD卡數(shù)據(jù)的方法,需要的朋友可以參考下

本文實(shí)例講述了android將Bitmap對(duì)象保存到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 對(duì)象 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();
 }
}

希望本文所述對(duì)大家的Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論