【发布时间】:2018-08-28 19:30:39
【问题描述】:
今天,我想用 C# 扫描一些二维码。因为,为什么不呢? 所以,我正在使用 Emgu(来自 NuGet 的包),当我尝试保存图像时,我收到了这个错误。
System.Runtime.InteropServices.ExternalException: 'A generic error occurred in GDI+.'
这是我正在使用的代码:
Capture capture = new Capture(); //create a camera capture
Bitmap image = capture.QueryFrame().Bitmap; //take a picture
image.Save((path + "data" + i.ToString() + ".jpg").Replace(" ", "_"));
这里有什么问题?
【问题讨论】:
-
使用 Path.Combine 创建正确的文件路径和名称。那个“替换”看起来是错误的,因为它会改变路径,因为“i”可能是一个数字。
-
您发布的哪一行会引发错误?向我们展示entire error message。
-
System.Runtime.InteropServices.ExternalException HResult=0x80004005 消息=GDI+ 中出现一般错误。 Source=System.Drawing StackTrace:在 System.Drawing.Image.Save(字符串文件名,ImageCodecInfo 编码器,EncoderParameters encoderParams)在 System.Drawing.Image.Save(字符串文件名,ImageFormat 格式)在 System.Drawing.Image.Save(字符串文件名)在 C:\Users\dev\source\repos\Demo\Demo\Program.cs:第 24 行中的 Demo.Program.Main(String[] args)
标签: c# memory computer-vision