我试图用涂鸦绘制一个白色的位图另一个位图,但结果总是白色的:
Bitmap myBitmap = mBitmap;
Canvas canvas = new Canvas(myBitmap);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
canvas.drawColor(0xffffffff);
canvas.drawBitmap(mBitmap, 0, 0, paint);
myBitmap.compress(CompressFormat.PNG, 100, output);
如何将白色作为背景,将画作作为画面中的前景?
答案 0 :(得分:0)
回答我对未来的问题的回答:
Bitmap bmOverlay = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), mBitmap.getConfig());
Bitmap bmp2 = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), mBitmap.getConfig());
Canvas canvas = new Canvas(bmOverlay);
bmp2.eraseColor(0xffffffff);
canvas.drawBitmap(bmp2, new Matrix(), null);
canvas.drawBitmap(mBitmap, new Matrix(), null);
bmOverlay是我们想要的最终位图。