How anti-aliasing in canvas and paths

I encounter a problem when I use canvas.clipPath, it shows a sawtooth, it looks nonsmooth, I know that if I used Paint, I can use mPaint.setFlags (Paint.ANTI_ALIAS_FLAG), it can smooth, but in my code, I can’t use paint.

public static void drawCurrentPageArea(Canvas canvas, Bitmap bitmap) { //cebakhja canvas.save(); canvas.clipPath(getPath5(), Region.Op.XOR); canvas.drawBitmap(bitmap, 0, 0, null); canvas.restore(); } public static Path getPath5() { Path mPath5 = new Path(); mPath5.moveTo(ptc.x, ptc.y); mPath5.quadTo(pte.x, pte.y, ptb.x,ptb.y); mPath5.lineTo(pta.x, pta.y); mPath5.lineTo(ptk.x, ptk.y); mPath5.quadTo(pth.x, pth.y, ptj.x,ptj.y); mPath5.lineTo(ptf.x, ptf.y); mPath5.close(); return mPath5; } 

you can see that I am using canvas.drawBitmap (bitmap, 0, 0, null); paint is zero. If I need to add paint, can you give some advice? fig. http://i.6.cn/cvbnm/36/5c/20/5d8d20e3bafe432d792793509f99131e.jpg

edit: I set the paint to be null but not affect

+4
source share
1 answer

Try it.

 private Paint mBitmapPaint = new Paint() { { setAntiAlias(true); setFilterBitmap(true); } }; public static void drawCurrentPageArea(Canvas canvas, Bitmap bitmap) { // cebakhja canvas.save(); canvas.clipPath(getPath5(), Region.Op.XOR); canvas.drawBitmap(bitmap, 0, 0, mBitmapPaint); canvas.restore(); } 
+9
source

All Articles