我創建了一個位圖,現在我想將該位圖保存到某個目錄。任何人都可以告訴我這是如何完成的。由於Android將創建的位圖保存到SD卡上的目錄
FileInputStream in;
BufferedInputStream buf;
try {
in = new FileInputStream("/mnt/sdcard/dcim/Camera/2010-11-16_18-57-18_989.jpg");
buf = new BufferedInputStream(in);
Bitmap _bitmapPreScale = BitmapFactory.decodeStream(buf);
int oldWidth = _bitmapPreScale.getWidth();
int oldHeight = _bitmapPreScale.getHeight();
int newWidth = 2592;
int newHeight = 1936;
float scaleWidth = ((float) newWidth)/oldWidth;
float scaleHeight = ((float) newHeight)/oldHeight;
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
Bitmap _bitmapScaled = Bitmap.createBitmap(_bitmapPreScale, 0, 0, oldWidth, oldHeight, matrix, true);
(我要救_bitmapScaled到一個文件夾我的SD卡上)
`newWidth = 2592`沒有把它拋出內存異常? – 2014-10-26 13:47:14
@MuhammadBabar它不會,如果他只是將其保存到磁盤,並不使用它在imageview – 2016-02-18 13:29:34