画布中的背景(图像),同时在顶部绘制路径

时间:2011-02-14 01:10:25

标签: java android graphics path bitmap

@Override protected void onDraw(Canvas canvas) {

        if (mBitmap != null) {

            canvas.drawColor(0xFFAAAAAA);

            canvas.drawBitmap(background,0,0,mBitmapPaint);

            if(isRelevant){
                canvas.drawBitmap(mBitmapLast, 0,0, mBitmapLastPaint);
            }

            canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
                canvas.drawPath(mPath, mPaint);
        }
    }

我尝试过切换

canvas.drawColor(0xFFAAAAAA);
                canvas.drawBitmap(background,0,0,mBitmapPaint);

canvas.drawColor(0xFFAAAAAA);为秒时,当我在屏幕上绘制它们时,我的路径会显示出来。有没有办法让背景(位图)显示在画布路径下?

1 个答案:

答案 0 :(得分:2)

尝试在路径的油漆中设置Xfermode

mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));  // or DST_OVER

并查看PorterDuff.Mode解释。