“GDI 中发生一般错误”在 Windows XP 中的浏览器中显示图像时出错

发布于 2025-01-03 07:56:26 字数 547 浏览 2 评论 0原文

在浏览器中显示 .tiff 图像时出现以下错误。

A generic error occurred in GDI+.

我将 .tiff 图像转换为 .png,然后在浏览器中显示它们。

我的代码:

Response.ContentType = "image/png";
Response.AddHeader("content-disposition", "filename=" + Request.QueryString["path"]);

Image img = Image.FromFile(Request.QueryString["path"]);               
      img.Save(Context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);

但是这个错误只出现在Windows XP中。相同的代码在 Windows 7 中运行良好。

I am getting following error while showing .tiff images in a browser.

A generic error occurred in GDI+.

I am converting .tiff images to .png and then displaying them in a browser.

My code:

Response.ContentType = "image/png";
Response.AddHeader("content-disposition", "filename=" + Request.QueryString["path"]);

Image img = Image.FromFile(Request.QueryString["path"]);               
      img.Save(Context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);

However this error only comes up in Windows XP. The same code is works fine in Windows 7.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦明 2025-01-10 07:56:27

尝试使用位图参考进行转换

System.Drawing.
 Bitmap.FromFile(Request.QueryString["path"])
  .Save(Context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);

Converting TIFF files to PNG in .Net< /a>

http://bytes.com/topic/c-sharp/answers/267798-convert-tiff-images-gif-jpeg

Try to convert it using the BitMap

System.Drawing.
 Bitmap.FromFile(Request.QueryString["path"])
  .Save(Context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);

reference :

Converting TIFF files to PNG in .Net

http://bytes.com/topic/c-sharp/answers/267798-convert-tiff-images-gif-jpeg

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文