我想在我的應用程序中畫線。完成後,我想將屏幕保存爲圖像。但我不想讓按鈕在圖像中。我想裁剪它然後保存它。我曾嘗試使用此代碼在onclicklistener中裁剪我的位圖。但它沒有奏效。 Bitmap.createBitmap(bitmap,5,5,5,5); 這是我的所有代碼:如何在Android中裁剪截圖
content.setDrawingCacheEnabled(true);
content.buildDrawingCache();
Bitmap bitmap = Bitmap.createBitmap(content.getDrawingCache()); // Bitmap
Bitmap.createBitmap(bitmap, 5, 5, 5, 5);
content.setDrawingCacheEnabled(false);
File file = new File("/sdcard/SurucuImza.jpg");
FileOutputStream ostream = null;
try {
if (bitmap != null) {
file.createNewFile();
ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.JPEG, 100, ostream);
ostream.flush();
ostream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
bitmap.recycle();
bitmap = null;
ostream = null;
content.setDrawingCacheEnabled(false);
}
http://stackoverflow.com/q/2085003/1007273 – hovanessyan 2012-08-15 12:31:29