September 7th, 2012, 10:16 PM
Smoother drawing pen
I have a C#/GDI+ paint application (winform) in which I draw different shapes with different colors and pen sizes. Now, the shape drawing I have handled, but using a 'free pen' as you would in MS Paint, I have also had it done but it is rather ugly (see pic).
(Meaning of most variables can be deduced but I can explain if necessary.)
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;
My app works that firstly I draw images on a bitmap (called 'bit' in this case), which are then created on a panel and then the panel paint event shows what I have drawn. But in this case, the pen is quite ugly, I assume because of the procedure: create graphics-draw line-draw on panel takes some time in between steps.
Is there a way to make this smoother?
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!