[英]How can i remove black background of after rotate Bitmap image in android 5.0
我試圖在我的代碼中旋轉圖像后刪除黑色背景
Bitmap rotate(float x, Bitmap bitmapOrg) {
int width = bitmapOrg.getWidth();
int height = bitmapOrg.getHeight();
int newWidth = 200;
int newHeight = 200;
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
matrix.postRotate(x);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, width,height, matrix, true);
//Canvas canvas = new Canvas(resizedBitmap);
//canvas.drawColor(Color.TRANSPARENT);
return resizedBitmap;
}
我怎么能刪除黑色背景我已經看到只有在我的Android lolipop,我也嘗試在我的模擬器谷歌galaxy nexus - 4.2.2在黑色背景不顯示。
你必須使用resizedBitmap.setHasAlpha(true);
在聲明位圖后立即放置該行代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.