2010-12-08 34 views
2

我是wpf控件和框架中的新成員。我似乎無法拯救我的圖片,你可以幫我 下面是我的代碼如何將圖像保存到WPF文件中

  SaveFileDialog sfd = new SaveFileDialog(); 
      sfd.FileName = System.IO.Path.GetFileNameWithoutExtension(newlist[currentPicture]);        
      Nullable<bool> result = sfd.ShowDialog(); 
      if (result == true) 
      { 

       System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(newlist[currentPicture]); 
       bmp.Save(newlist[currentPicture]); 
      } 
+0

這不是WPF。 – SLaks 2010-12-08 01:13:35

+0

你應該接受你的問題的答案。 – SLaks 2010-12-08 01:14:15

回答

3

對於System.Drawing.Bitmap,你需要在對話框的FileName屬性傳遞到保存方法。

編輯:在WPF:

var encoder = new PngBitmapEncoder() 
encoder.Frames.Add(BitmapFrame.Create(image)); 
using (var stream = dialog.OpenFile()) 
    encoder.Save(stream); 
相關問題