![]() ![]() G.DrawLines(pen, points.ToArray()) // Just draw current line on bitmap Points.Clear() // Our drawing is saved, we can clear the list of points ![]() SaveToBitmap() // Save the drawn line to bitmap Void OnMouseUp(object sender, MouseEventArgs e) Points.Add(e.Location) // Add points to path Void OnMouseMove(object sender, MouseEventArgs e) Points.Add(e.Location) // Remember the first point Void OnMouseDown(object sender, MouseEventArgs e) Void OnPaint(object sender, PaintEventArgs e)Į.Graphics.DrawImage(bmp, 0, 0) // Show what is drawnĮ.Graphics.DrawLines(pen, points.ToArray()) // Show what is currently being drawn MouseDown += OnMouseDown // Start drawing Points = new List() // Here we will remember the whole path G.Clear(Color.White) // Let's make it white, like paper Using (Graphics g = Graphics.FromImage(bmp)) Private Pen pen // Pen we will use to drawĭoubleBuffered = true // To avoid flickering effectīmp = new Bitmap(640, 480) // This is our canvas that will store drawn lines Private List points // Points of currently drawing line Private Bitmap bmp // Place to store our drawings Comments in code should explain how it works. Just create a new project and copy this code below to Form1.cs file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |