我有三个图像视图,我正在尝试使用以下代码将每个位图保存到文件中。
private WriteImage writeimage
writeImage = new WriteImage();
writeImage.WriteImageToDisk(((BitmapDrawable)img_view_left.getDrawable()).getBitmap(),ex.get(0).getLeftPhoto());
writeImage.WriteImageToDisk(((BitmapDrawable)img_view.getDrawable()).getBitmap(),ex.get(0).getPhoto());
writeImage.WriteImageToDisk(((BitmapDrawable)img_view_right.getDrawable()).getBitmap(),ex.get(0).getRightPhoto());
public class WriteImage {
public void WriteImageToDisk(Bitmap bitmap, String url){
FileOutputStream outStream = null;
File file;
try {
file = new File(url);
outStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 60, outStream);
outStream.flush();
outStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
但它只保存第一张图片而不保存其他两张图片
为什么会这样?