我必须在用户做一些事情后用原始图像创建新的位图,如缩放,旋转,拖动。我有一个框架边框,只有部分原始图像放在框架上。问题是框架的剩余区域是黑色的,我希望它可以是透明的或白色的。怎么做?提前谢谢。
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;
}
答案 0 :(得分: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;
}