【问题标题】:"A generic error occurred in GDI+" Error while showing Images in browser in Windows XP在 Windows XP 的浏览器中显示图像时出现“GDI+ 中发生一般错误”错误
【发布时间】:2012-02-07 06:54:55
【问题描述】:

在浏览器中显示.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 中运行良好。

【问题讨论】:

    标签: c# asp.net image tiff


    【解决方案1】:

    尝试使用位图进行转换

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

    参考:

    Converting TIFF files to PNG in .Net

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

    【讨论】:

      猜你喜欢
      • 2011-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-26
      • 1970-01-01
      • 1970-01-01
      • 2015-07-02
      • 1970-01-01
      相关资源
      最近更新 更多