将Bitmap保存为本地图片

时间:2014-05-09 05:03:19   收藏:0   阅读:306

public boolean saveMyBitmap(Bitmap bmp, String bitName) throws IOException {
boolean flag = false;
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{

// 获得存储卡的路径
String sdpath = Environment.getExternalStorageDirectory() + "/";
String mSavePath = sdpath + "lzrc/imgs";

File f = new File(mSavePath, bitName);

f.createNewFile();
FileOutputStream fOut = null;
try {
fOut = new FileOutputStream(f);
bmp.compress(Bitmap.CompressFormat.PNG, 100, fOut);
flag = true;
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
fOut.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}

}
return flag;
}

将Bitmap保存为本地图片,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!