2

I have a paint program made in C#/GDI+ in which I draw different shapes with interchangeable colors and pen sizes on a panel. I have got the shape-drawing methods working OK, but when it comes to using a free pen (as you would in MS Paint) I have made a method that does the job, just quite ugly (see pic in link).

if (crtanje)
            {
                debljina = float.Parse(debljina_box.Text);
                Graphics gr = Graphics.FromImage(bit);
                gr.SmoothingMode = SmoothingMode.HighQuality;
                olovka = new Pen(boja, debljina);
                gr.DrawLine(olovka, new Point(prethodnoX ?? e.X, prethodnoY ?? e.Y), new Point(e.X, e.Y));
                panel1.CreateGraphics().DrawImageUnscaled(bit, new Point(0, 0));
                prethodnoX = e.X;
                prethodnoY = e.Y;
            }

Can this code be fixed to make drawing smoother or should I take some other approach?

the pic

  • This is a problem with the refresh rate of the program, even photoshop does that on a slow computer like mine. You could probably interpolate between the points to make it smoother. – annonymously Sep 08 '12 at 02:25

1 Answers1

0

I suppose you could iterate through a for loop and increase it by a very small amount so that it draws points more frequently and makes the line smoother. You could save the current point and calculate the next one, then draw a line between them. That's how you could make it smoother!

Asen Georgiev
  • 21
  • 1
  • 5