i meet a trouble when i use canvas.clipPath,it show sawtooth,it looks not smooth,i know if i used a Paint,i can use mPaint.setFlags(Paint.ANTI_ALIAS_FLAG) ,this can antialiasing ,but in my code ,i cannot 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 i use canvas.drawBitmap(bitmap, 0, 0, null); paint is null.if i need add a paint ,can you have some advice? the pic is as http://i.6.cn/cvbnm/36/5c/20/5d8d20e3bafe432d792793509f99131e.jpg
edit:i set the paint that is null ,but not effect
Try this.
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With