File f = new File("/sdcard/kkpy/image" + getString(etv_name) + ".png");
try {
f.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("在保存图片时出错:" + e.toString());
}
FileOutputStream fOut = null;
try {
fOut = new FileOutputStream(f);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
QR_bmp.compress(Bitmap.CompressFormat.PNG, 100, fOut);
try {
fOut.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
保存bitmap到sdcard
最新推荐文章于 2021-05-27 02:29:24 发布
本文介绍了如何在Java中创建并保存图片文件,包括获取输入文本框内容、创建目标文件路径、使用FileOutputStream进行文件输出,并通过Bitmap.CompressFormat.PNG进行压缩。遇到异常时,程序会捕获并打印错误信息。
830

被折叠的 条评论
为什么被折叠?



