4

我在使用 canvas.clipPath 时遇到问题,它显示锯齿,看起来不平滑,我知道我是否使用了 Paint,我可以使用 mPaint.setFlags(Paint.ANTI_ALIAS_FLAG),这可以抗锯齿,但在我的代码中,我不能使用油漆。

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

你可以看到我使用 canvas.drawBitmap(bitmap, 0, 0, null); 油漆是空的。如果我需要添加油漆,你能给点建议吗?图片为http://i.6.cn/cvbnm/36/5c/20/5d8d20e3bafe432d792793509f99131e.jpg

编辑:我设置为空的油漆,但没有效果

4

1 回答 1

9

尝试这个。

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();
}
于 2012-04-04T10:03:40.867 回答