已經imagview希望將其保存到存儲器這裏是我的代碼:如何從ImageView保存圖像?
View content = findViewById(R.id.full_image_view);
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
File root = Environment.getExternalStorageDirectory();
File cachePath = new File(root.getAbsolutePath() + "/DCIM/Camera/image.jpg");
try {
root.createNewFile();
FileOutputStream ostream = new FileOutputStream(root);
bitmap.compress(CompressFormat.JPEG, 100, ostream);
ostream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
保存沒有任何反應後,沒有圖像是存在嗎?
圖像保存,但它的不可讀像它curupted ? – Soheyl
@Sheheyl你是否改變了這一點。如果不改變並嘗試'FileOutputStream ostream = new FileOutputStream(cachePath);' – Hariharan