Timothy Miller
Timothy Miller

Reputation: 291

background (image) in canvas while drawing path over the top

@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);
        }
    }

I've tried switching around the lines

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

and when canvas.drawColor(0xFFAAAAAA); is second, my paths will show up when I draw them on the screen. Is there a way to make the background (bitmap) show underneath the canvas paths?

Upvotes: 0

Views: 1739

Answers (1)

xandy
xandy

Reputation: 27421

Try setting the Xfermode in your Path's paint:

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

and see PorterDuff.Mode explained.

Upvotes: 2

Related Questions