日期:2014-05-17  浏览次数:20480 次

输出图片提示错误:GDI+ 中发生一般性错误。
我在本机测试的时候没有问题,发布到IIS6出现:GDI+ 中发生一般性错误。
我的源代码是:

  string fullpath = HttpContext.Current.Server.MapPath("/logo.png");

  using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(fullpath))
  {
  bitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
  }
麻烦高手,,,告诉我哪里错了,我是新手。。。

------解决方案--------------------
试一试先保存到MemoryStream中,再Response回去。

using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(fullpath))
{
using(MemoryStream ms = new MemoryStream())
{
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
Response.BinaryWrite(ms.ToArray());
}
}

手写代码,可能有些许错误。