【问题标题】:ReadFile image and then overwrite it - A generic error occurred in GDI读取文件图像,然后覆盖它 - GDI 中发生一般错误
【发布时间】:2013-06-09 04:06:06
【问题描述】:

我只是想不通如何解决这个问题。 尝试了我发现的大多数建议都没有成功。

newMember.Me_Photo = ReadFile("C:/Users/Leta/Documents/Visual Studio 2012/Projects/PkExtreme/tempImage.jpg");
(new Bitmap("C:/Users/Leta/Documents/Visual Studio 2012/Projects/PkExtreme/PkExtreme/initialMemberPic1.jpg")).Save("C:/Users/Leta/Documents/Visual Studio 2012/Projects/PkExtreme/tempImage.jpg");

如果用户没有另外指定,则使用默认图像,之后将被另一个基本上是默认图像的图像覆盖。

【问题讨论】:

  • 调用new Bitmap或调用.Save时是否出现异常?
  • 如果您需要帮助,那么您应该说明哪个函数调用引发了异常。并且给出 ReadFile 的定义也会有所帮助。
  • 它发生在第二行,当试图保存图像时。 ReadFile 接受字符串参数。我通过添加 if 条件并检查用户是否定义了图像来克服这个错误。如果他有则执行第一行,否则执行此行:newMember.Me_Photo = ReadFile("C:/Users/Leta/Documents/Visual Studio 2012/Projects/PkExtreme/PkExtreme/initialMemberPic1.jpg");

标签: c# image gdi+ readfile overwrite


【解决方案1】:

你的问题可能是由于这个目录:

"C:/Users/Leta/Documents/Visual Studio 2012/Projects/PkExtreme/PkExtreme/initialMemberPic1.jpg"

请注意,您有两个 /PkExtreme 子文件夹。如果此目录(包含两个 PkExtreme 子文件夹)实际上不存在于磁盘上,您可能会收到一般 GDI 错误。

【讨论】:

  • 它们确实存在。我尝试删除 tempImage.jpg 然后复制 initialMemberPic1.jpg 但收到错误提示 tempImage.jpg 正在被其他来源使用...
猜你喜欢
  • 2011-06-04
  • 2010-11-06
  • 2013-09-26
  • 1970-01-01
  • 1970-01-01
  • 2015-07-02
  • 2011-01-12
  • 2020-10-29
相关资源
最近更新 更多