Android 我可以在画布上使用抗锯齿进行绘制吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10465191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:50:34  来源:igfitidea点击:

Can I draw with antialiasing on canvas?

androidgraphicsandroid-canvasantialiasing

提问by Suzan Cioc

Can I draw with anti-aliasing on canvas?

我可以在画布上使用抗锯齿进行绘制吗?

I need my circles and line have smooth edges.

我需要我的圆圈和线条边缘平滑。

回答by Alexander Kulyakhtin

Drawing operations want Paint. In this Paintyou set Paint.setFlags(Paint.ANTI_ALIAS_FLAG)

绘图操作要Paint。在这个Paint你设置Paint.setFlags(Paint.ANTI_ALIAS_FLAG)

回答by Arun Chettoor

Check this out. It fairly uses smooth edges.. http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.html

看一下这个。它相当使用平滑边缘.. http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.html

The paint properties needed to get anti-aliasing is :

获得抗锯齿所需的绘制属性是:

     mPaint = new Paint();
     mPaint.setAntiAlias(true);

For drawing use:

用于绘图:

     mPath = new Path();
     mPath.reset();
     mPath.moveTo(x, y);//can be used where to trigger the path

onDraw method should contain:

onDraw 方法应包含:

     canvas.drawPath(mPath, mPaint);

Declare the mPath and mPaint as global.

将 mPath 和 mPaint 声明为全局。