在画布上缩放后,路径上的抗锯齿

时间:2014-11-17 15:24:03

标签: java android android-canvas

我有一个应用程序在屏幕上绘制一些形状。问题是抗锯齿不能处理我使用Path绘制的形状,但只能在缩放(缩放)之后。 另一方面,绘制圆圈没有问题(即使在缩放后)。缩放工作正常,之后形状不明显。

...
// Matrix m = new Matrix();
// m.setValues(createMatrix());
// canvas.concat(m);
//or
canvas.scale(6.0f, 6.0f); // the upper code is used on real, but the same problem occures with this call
...
RectF oval = new RectF(x, y, x + width, y + height);
currentPaint.setAntiAlias( true );
canvas.drawOval(oval, currentPaint);

currentPaint.setAntiAlias( true );
canvas.drawPath(getPathOfShape(), currentPaint);

有人可以帮我吗?

1 个答案:

答案 0 :(得分:3)

我找到了问题的原因。问题是,如果硬件加速已启用,则不会从android支持。禁用硬件加速后,缩放工作正常。

view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

有关此内容的详细信息,请访问google网站:

http://developer.android.com/guide/topics/graphics/hardware-accel.html