2

我正在使用画布绘制图表。

位图图像;

image= //这里我得到了我想在画布上绘制的位图

画布画布=新画布(图像);

//我有如下画圈

canvas.drawCircle(cx, cy, 半径, 油漆);

但圆角不尖:

ii 显示的是这样的:

在此处输入图像描述

我如何使圆外半径尖锐..

提前致谢..

4

3 回答 3

4

初始化绘画时,请设置以下属性:

paint.setAntiAlias(true);
paint.setDither(true);
paint.setFilterBitmap(true);

请参阅 Android 文档了解每个功能的作用;

http://developer.android.com/reference/android/graphics/Paint.html

于 2012-09-17T07:53:23.987 回答
1

let's say:

cx = 108.0F;
cy = 108.0F;
radius = 88.0F;
canvas.drawCircle(cx, cy, radius, paint);

Example:

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
于 2014-05-26T17:34:30.930 回答
1

设置反别名

paint.setAntiAlias(true);

于 2012-09-17T07:54:39.873 回答