我正在使用画布绘制图表。
位图图像;
image = //这里我得到我想在画布上绘制的位图
Canvas canvas = new Canvas(image);
//我画了一个圆圈如下
canvas.drawCircle(cx,cy,radius,paint);
但是圆角并不尖锐:
ii显示的内容如下:
如何使圆外半径锐利..
提前致谢..
答案 0 :(得分:4)
初始化油漆时,请设置以下属性:
paint.setAntiAlias(true);
paint.setDither(true);
paint.setFilterBitmap(true);
请参阅Android文档,了解每个人的工作内容;
http://developer.android.com/reference/android/graphics/Paint.html
答案 1 :(得分:1)
设置反别名
paint.setAntiAlias(true);
答案 2 :(得分:1)
让我们说:
cx = 108.0F;
cy = 108.0F;
radius = 88.0F;
canvas.drawCircle(cx, cy, radius, paint);
示例:
Paint p = new Paint();
p.setAntiAlias(true);
p.setFilterBitmap(true);
p.setDither(true);
p.setColor(Color.WHITE);
p.setStrokeWidth(3.75F);
p.setStyle(Paint.Style.STROKE);
Bitmap bmp1 = Bitmap.createBitmap(216, 216, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp1);
canvas.drawCircle(108.0F, 108.0F, 88.0F, p); // since the bitmap size is 216
//then, the starting (x) and the end (y) points must begin from
//the center to be a nice circle, that's why I used 108 as 108*2 = 216.
//and the 88 is the radius of the desired circle