September 4th, 2012, 11:26 AM
Save image drawn on Panel
I have a C#/GDI+ paint program (winform app.) in which I draw certain images (ellipses and rectangles) with interchangeable colors and pen sizes on a panel using MouseUp/Down/Move events (not Paint event). Everything is working but I can't seem to be able to save what I have drawn on the panel? Could someone help?
Thanks in advance!
September 5th, 2012, 01:15 AM
Re: Save image drawn on Panel
It is not particularly common to use a Panel for drawing. In any case you need to creat a Graphics object, then an image from this Graphics object - then, you could draw and save virtually anything on anything.
for example :
Then you use the gr object to draw and the img object to save :
Graphics displayGraphics = this.CreateGraphics();
Image img = new Bitmap(this.Width, this.Height, displayGraphics);
Graphics gr = Graphics.FromImage(img);
That gives you more or less an idea of what to do
gr.DrawEllipse(MYPEN, 270, 160, 30, 30);
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.