2

I draw a rectangle on a bitmap and its borders are antialiased or have some effects as you can see: enter image description here original image: enter image description here

How to switch off that effect to get solid lines like this:

enter image description here enter image description here

I use this code:

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);
Zsolt
  • 365
  • 3
  • 12

1 Answers1

0

My impression is that your bitmap is correctly drawn without anti-aliasing, but the blurry effect may come from the magnification when displaying the bitmap. Your screenshot is 245 pixels wide, but your code seems to indicate that the rectangle should be about 50 pixels or so.

Rémi
  • 3,705
  • 1
  • 28
  • 39
  • These images are zoomed in to let you see what I am talking about. This blurry effect is not by zooming! When I draw a simple line the effect is the same. – Zsolt Sep 16 '13 at 15:11
  • Sorry my guess was wrong. Maybe the problem is in the units. What happens if you set the StrokeWidth to 0? – Rémi Sep 16 '13 at 15:29
  • I tried that already. Unfortunately the same. First I wanted to draw a simple filled rectangle and it had the same borders. I was surprised when I draw some text and the effect was the same. If I draw text with no antialiasing, then it has slight antialias, but when I turn antialiasing on then I can feel the differece, it is much more antialiased. Don't understand. – Zsolt Sep 16 '13 at 18:49