canvas 上的蒙版位图具有透明 activity
Masked bitmap on canvas with transparent activity
我为 activity
实现了自定义 ShowCase
我正在尝试在 canvas 面具上画画:
http://i.stack.imgur.com/u23kQ.png
遵循此代码:
mCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
// draw solid background
mCanvas.drawColor(mMaskColour);
// Prepare eraser Paint if needed
if (mEraser == null) {
mEraser = new Paint();
mEraser.setColor(0xFFFFFFFF);
mEraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
mEraser.setFlags(Paint.ANTI_ALIAS_FLAG);
}
// draw (erase) shape
// mShape.draw(mCanvas, mEraser, mXPosition, mYPosition, mShapePadding);
mCanvas.drawBitmap(cBitmap,mXPosition,mYPosition,mEraser);
// Draw background
canvas.drawBitmap(mBitmap, 0, 0, null);
但它看起来像这样:
我解决了这个问题
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mCanvas.drawBitmap(cBitmap,mXPosition,mYPosition,paint);
// mShape.draw(canvas, mEraser, mXPosition, mYPosition, mShapePadding);
// Draw the bitmap on our views canvas.
canvas.drawBitmap(mBitmap, 0, 0, null);
我为 activity
实现了自定义 ShowCase我正在尝试在 canvas 面具上画画: http://i.stack.imgur.com/u23kQ.png
遵循此代码:
mCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
// draw solid background
mCanvas.drawColor(mMaskColour);
// Prepare eraser Paint if needed
if (mEraser == null) {
mEraser = new Paint();
mEraser.setColor(0xFFFFFFFF);
mEraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
mEraser.setFlags(Paint.ANTI_ALIAS_FLAG);
}
// draw (erase) shape
// mShape.draw(mCanvas, mEraser, mXPosition, mYPosition, mShapePadding);
mCanvas.drawBitmap(cBitmap,mXPosition,mYPosition,mEraser);
// Draw background
canvas.drawBitmap(mBitmap, 0, 0, null);
但它看起来像这样:
我解决了这个问题
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mCanvas.drawBitmap(cBitmap,mXPosition,mYPosition,paint);
// mShape.draw(canvas, mEraser, mXPosition, mYPosition, mShapePadding);
// Draw the bitmap on our views canvas.
canvas.drawBitmap(mBitmap, 0, 0, null);