0
我使用colorfilterAndroid的保存畫布SD
這是我的代碼
int color = mPaint.getColor();
f = new LightingColorFilter(color, 1);
mPaint.setColorFilter(f);
myBmp = BitmapFactory.decodeResource(getResources(), R.drawable.icon10);
canvas.drawBitmap(myBmp, 20, 20, mPaint);
canvas.save();
canvas.restore();`
創建畫布上的圖像,然後,我想將它保存到SD卡
OutputStream outStream = null;
File file = new File(extStorageDirectory, "er.PNG");
try {
outStream = new FileOutputStream(file);
myBmp.compress(Bitmap.CompressFormat.PNG, 85, outStream);
outStream.flush();
outStream.close();
Toast.makeText(Draw.this, "Saved", Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(Draw.this, e.toString(), Toast.LENGTH_LONG).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(Draw.this, e.toString(), Toast.LENGTH_LONG).show();
}
它的工作但有問題,我在SD上的圖片是舊圖片(不是過濾器)
我可以修復這個問題??謝謝
只需刪除舊的並保存新的,或者,最好只是重新命名爲filename +「_filtered.png」。 –