CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2012
    Posts
    2

    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!

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    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
  •  





Click Here to Expand Forum to Full Width

Featured