2011-11-06 59 views
0

如果我有一個繪製矩形,圓形和線條的程序,並且我想要使用SaveFileDialog保存用戶在表單上繪製的圖片,那麼這將如何完成?如何使用SaveFileDialog保存表單

我知道如何使用SaveFileDialog保存文本文件,只是不知道如何保存表單。

+0

你知道如何捕捉圖像繪製的? –

回答

4

你可以試試這個....

它將保存表單內容,位圖SaveFileDialog

public class Form1 
    { 

     private Bitmap objDrawingSurface;   
     private Rectangle rectBounds1; 

     private void Button1_Click(object sender, System.EventArgs e) 
     { 
     objDrawingSurface = new Bitmap(this.Width, this.Height, Imaging.PixelFormat.Format24bppRgb); 
     rectBounds1 = new Rectangle(0, 0, this.Width, this.Height); 
     this.DrawToBitmap(objDrawingSurface, rectBounds1); 
     SaveFileDialog sfd = new SaveFileDialog(); 
     sfd.Filter = "JPG Files (*.JPG) |*.JPG"; 
     if ((sfd.ShowDialog == Windows.Forms.DialogResult.OK)) 
     { 
      objDrawingSurface.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); 
     } 
    } 
    } 
+0

@ errorstacks謝謝:) – BigBug

1
public void SaveFormToFile(string fileName) 
{ 
    System.Drawing.Bitmap b = new Bitmap(this.Bounds.Width, this.Bounds.Height); 
    this.DrawToBitmap(b, this.Bounds); 
    b.Save(fileName); 
} 
相關問題