将图像输出到输出流时,是否需要临时存储?在将图像保存到文件时,我收到通常与文件夹权限错误相关的"通用GDI +"错误.
我正在对图像做的唯一事情是添加一些文本.即使我直接输出图像而没有修改,我仍然会得到错误.例如,这样做会给我错误:
using (Bitmap image = new Bitmap(context.Server.MapPath("images/stars_5.png")))
{
image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
}
Run Code Online (Sandbox Code Playgroud)
在运行带有IIS 7.5和ASP.NET 2.0的Windows 7的本地计算机上,一切正常.问题出现在运行带有IIS 6和ASP.NET 2.0的Windows Server 2003的QA服务器上.
给出错误的行是:
image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪:
[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
Run Code Online (Sandbox Code Playgroud)