簡體   English   中英

從圖片框導出圖像時出錯“ GDI +中發生一般錯誤。 “ C#

[英]Error in exporting image from picturebox “ A generic error occurred in GDI+. ” C#

從pictureBox導出圖像時出現錯誤

“ GDI +中發生一般錯誤”

**********例外文字**********

System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at Soccer_Studio.Form1.button2_Click(Object sender, EventArgs e) in ***********************\Form1.cs:line 137
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

這是我的代碼

 using (Bitmap tempImage = new Bitmap(pictureBox1.Image))
            {
                pictureBox1.Image.Save(@"C:\Users\Mena\Desktop", System.Drawing.Imaging.ImageFormat.Bmp);
            }

代碼有什么問題?

您可能需要一個文件名...

pictureBox1.Image.Save(@"C:\Users\Mena\Desktop\file.bmp",
    System.Drawing.Imaging.ImageFormat.Bmp);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM