将图像输出到输出流时,是否需要临时存储?我得到了"通用GDI+"错误,这通常与将图像保存到文件时的文件夹权限错误有关.
我对图像所做的唯一一件事就是添加一些文本.即使我直接输出图像而不做任何修改,我仍然会出错.例如,这样做会产生错误:
using (Bitmap image = new Bitmap(context.Server.MapPath("images/stars_5.png")))
{
image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
}
在我的本地机器上运行Windows 7和IIS 7.5及ASP,一切正常.NET 2.0.问题发生在运行带有IIS 6和ASP的Windows server 2003的QA服务器上.NET 2.0.
给出错误的行是:
image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
以下是堆栈跟踪:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) +378002
System.Drawing.Image.Save(Stream stream, ImageFormat format) +36
GetRating.ProcessRequest(HttpContext context) in d:\inetpub\wwwroot\SymInfoQA\Apps\tools\Rating\GetRating.ashx:54
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75