Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make drawLine smoother?

I use the following code to draw line:

Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Black,3);
g.DrawLine(p,...);
// ...

Why the straight line is zigzag kind of, not straight and smooth at all. How could I make it straight and smoother?

like image 561
spspli Avatar asked Apr 06 '11 15:04

spspli


1 Answers

You need to enable anti-aliasing. Set Graphics.SmoothingMode to AntiAlias as described here: http://msdn.microsoft.com/en-us/library/system.drawing.graphics.smoothingmode.aspx

like image 133
Agnel Kurian Avatar answered Sep 29 '22 15:09

Agnel Kurian