Android:没有抗锯齿的drawRect

时间:2013-09-16 14:54:59

标签: android border drawrect antialiasing

我在位图上绘制一个矩形,其边框是抗锯齿的或具有一些效果,如您所见: enter image description here原始图片:enter image description here

如何关闭该效果以获得这样的实线:

enter image description here enter image description here

我使用此代码:

Bitmap mBuffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
gfx = new Canvas(mBuffer);

Paint paintNorm = new Paint();
paintNorm.setAntiAlias(false);
paintNorm.setStrokeWidth(1);
paintNorm.setStyle(Paint.Style.STROKE);
paintNorm.clearShadowLayer();
paintNorm.setDither(false);
paintNorm.setFilterBitmap(false);

paintNorm.setColor(0xFFA8A8A8);
gfx.drawRect(2,3,50,50, paintNorm);

1 个答案:

答案 0 :(得分:0)

我的印象是你的位图是在没有消除锯齿的情况下正确绘制的,但模糊效果可能来自显示位图时的放大率。您的屏幕截图宽度为245像素,但您的代码似乎表明该矩形大约应为50像素左右。

相关问题