-
September 4th, 2012, 11:26 AM
#1
Save image drawn on Panel
Hello
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
#2
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 :
Code:
Graphics displayGraphics = this.CreateGraphics();
Image img = new Bitmap(this.Width, this.Height, displayGraphics);
Graphics gr = Graphics.FromImage(img);
Then you use the gr object to draw and the img object to save :
Code:
gr.DrawEllipse(MYPEN, 270, 160, 30, 30);
img.Save("C:\\test.jpg");
That gives you more or less an idea of what to do
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|