Question

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()?

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top