在Android

时间:2017-10-03 01:52:46

标签: android graphics android-canvas paint antialiasing

我想要得到的东西:

enter image description here

我得到了什么:

enter image description here

我通过连接两个连续坐标来绘图:

Paint paint = new Paint();
paint.setColor(Color.DKGRAY);
paint.setStrokeWidth(75);
paint.setStrokeCap(Paint.Cap.ROUND);

// Tried without success:
paint.setAntiAlias(false);

// Also tried without success:
paint.setAntiAlias(true);

// Loop list<Point>; keep track of previous Point
canvas.drawLine(xPrev, yPrev, x, y, paint);

2 个答案:

答案 0 :(得分:1)

使用paint.setAntiAlias(true);获得平滑效果。

或使用paint.setMaskFilter(new BlurMaskFilter(/*args*/));进行模糊效果。

还要确保从Android清单中关闭硬件加速。

如果它仍未达到预期效果,请在绘图时使用抗锯齿,然后按比例缩小和放大,或者如果可能,绘制小尺寸路径并将其放大。

答案 1 :(得分:-1)

尝试使用paint.setStrokeCap(Paint.Cap.ROUND);paint.setStrokeJoin()。希望它有所帮助

相关问题