2

I m drawing in a bitmap like..

bitmap[i] = new Bitmap(60, 60);  
Graphics g = new Graphics(bitmap[i]);
g.setColor(Color.BLACK);
g.drawLine(....);

Now how to set Anti-Aliasing on before g.drawLine()?

Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
Shreyas
  • 209
  • 1
  • 7
  • 16

1 Answers1

3

For antialiasing mode use public void setDrawingStyle(int drawStyle, boolean on)

For lines use

graphics.setDrawingStyle(Graphics.DRAWSTYLE_AALINES, true);
graphics.drawLine(x1, y1, x2, y2);
graphics.setDrawingStyle(Graphics.DRAWSTYLE_AALINES, false);

For poligons use

graphics.setDrawingStyle(Graphics.DRAWSTYLE_AAPOLYGONS, true);
graphics.drawRect(x, y, width, height);
graphics.setDrawingStyle(Graphics.DRAWSTYLE_AAPOLYGONS, false);
Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
  • Thanks.. I cant see its effect in Simulator. I will test it on Storm. – Shreyas Aug 31 '09 at 06:47
  • 1
    The flag `DRAWSTYLE_AAPOLYGONS` also applies to circles and ellipses. Its effect is perceptible in simulators, but you'll probably need to increase zoom to 4x. – Mister Smith Sep 04 '12 at 08:47