2013-03-13 67 views
0

我必須從用原始圖像創建新的位圖後用戶做一些事情,像放大,旋轉,拖動。我有一個框架邊框,只有部分原始圖像躺在框架上被挑選出來。問題是幀的剩餘區域是黑色的,我希望它可以是透明或白色的。怎麼做?提前致謝。用黑色保留區域問題創建新的位圖

enter image description here enter image description here

public Bitmap createBitmap(final Matrix pMatrix, final Bitmap pSourceBitmap){ 

    Bitmap bmp = Bitmap.createBitmap(width, height, pSourceBitmap.getConfig()); 

Canvas canvas = new Canvas(bmp); 
    canvas.drawBitmap(pSourceBitmap, pMatrix, new Paint()); 

    return bmp; 
} 

回答

1

爲了使剩餘部分透明

使用下面的代碼

public Bitmap createBitmap(final Matrix pMatrix, final Bitmap pSourceBitmap) 
{ 
    Bitmap.Config conf = Bitmap.Config.ARGB_8888; 
    Bitmap bmp= Bitmap.createBitmap(width, height, conf); 
    Canvas canvas = new Canvas(bmp); 
    canvas.drawBitmap(pSourceBitmap, pMatrix, new Paint()); 

    return bmp; 
} 
+0

謝謝,我也想通了,前幾天 – Kiradev 2013-03-18 02:10:01

+0

感謝,但我想圖像居中。 – Prasad 2014-09-10 07:34:32

相關問題