// 该函数用来对得到的图像进行存储
public void saveMyBitmap(String bitName, byte[] b)
{
//首先将byte数组转为bitmap
Bitmap mBitmap = Bytes2Bimap(b);
//创建文件对象,用来存储新的图像文件
File f = new File(Environment.getExternalStorageDirectory()
+ "/Terminal/" + bitName + ".jpg");
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();
}
//将bitmap存储为jpg格式的图片
mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
try
{
//刷新文件流
fOut.flush();
} catch (IOException e)
{
e.printStackTrace();
}
try
{
//关闭文件流
fOut.close();
} catch (IOException e)
{
e.printStackTrace();
}
}