GDI 中的 C# 通用错误保存图像时
当我尝试使用 System.Drawing.Image.Save(String) 或 System.Drawing.Bitmap.Save(String) 保存图像时,会抛出异常,指示GDI+ 中的一般错误。搜索网络和 Stack Overflow 表明我应该确保不关闭图像来源的流,但就我而言,图像是通过第 3 方库从互联网下载的,我无法控制它的流是从中读取的(如果甚至是从流中读取的)
我尝试了一些操作,例如复制图像,但我总是遇到相同的错误。关于如何解决这个问题有什么想法吗?
When I try to save an image using either System.Drawing.Image.Save(String)
or System.Drawing.Bitmap.Save(String)
an exception is throw indicating a generic error in GDI+. Searching the web and Stack Overflow shows that I should be making sure I don't close the stream the image came from, but in my case the image was downloaded from the internet through a 3rd party library and I have no control over the stream it was read from (if it was even read from a stream)
I've tried a few things such as copying the image, but I always get the same error. Any ideas on how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我过去也有过这样的经历。确保您对保存文件的位置具有写入权限。
I've had this in the past. Make sure you have write permissions to wherever you're saving the file.
尝试使用 Save(String, ImageFormat) 重载。图像格式推断似乎效果不是特别好。
Try using the Save(String, ImageFormat) overload. The image format inference doesn't appear to work particularly well.