public String saveImage(Bitmap bmp) {
File appDir = new File(Environment.getExternalStorageDirectory(), "Boohee");
if (!appDir.exists()) {
appDir.mkdir();
}
String fileName = System.currentTimeMillis() + ".jpg";
File file = new File(appDir, fileName);
try {
FileOutputStream fos = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return file.getAbsolutePath();
}
用 Zxing 生成二维码 并保存到本地的时候 会看到保存本地的是一张黑色的图 但是用imageview 看到的正常的
因为 imageview 在显示图片时 默认不没有颜色的地方设置成白色了 但是 保存到本地时 它会将没有颜色的地方默认显示成黑色 所有你看到的是全黑色的
解决方案是 在Zxing 生成图片的时候 加上该代码
![](https://images2015.cnblogs.com/blog/764117/201612/764117-20161228180439414-1365927067.png)