ASP.NET中“A generic error occurred in GDI+.”
代码:privatevoidZoomPic(HttpContextcontext,System.Drawing.Imageoimage,intdesWidth,intde...
代码:
private void ZoomPic(HttpContext context, System.Drawing.Image oimage, int desWidth, int desHeight)
{
Bitmap bmpTemp = new Bitmap(oimage);
Bitmap bmp = new Bitmap(bmpTemp);
Graphics g = Graphics.FromImage(bmp);
bmpTemp.Dispose();
bmp.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
错误描述:
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
at SunOA.Web.ActionForm1.ZoomPic(HttpContext context, Image oimage, Int32 desWidth, Int32 desHeight)
at SunOA.Web.ActionForm1.GetPersonPhoto(HttpContext context) 展开
private void ZoomPic(HttpContext context, System.Drawing.Image oimage, int desWidth, int desHeight)
{
Bitmap bmpTemp = new Bitmap(oimage);
Bitmap bmp = new Bitmap(bmpTemp);
Graphics g = Graphics.FromImage(bmp);
bmpTemp.Dispose();
bmp.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
错误描述:
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
at SunOA.Web.ActionForm1.ZoomPic(HttpContext context, Image oimage, Int32 desWidth, Int32 desHeight)
at SunOA.Web.ActionForm1.GetPersonPhoto(HttpContext context) 展开
3个回答
展开全部
尝试这两行代码换个位置:
bmpTemp.Dispose();
bmp.Save(context.Response.OutputStream, ImageFormat.Jpeg);
bmpTemp.Dispose();
bmp.Save(context.Response.OutputStream, ImageFormat.Jpeg);
更多追问追答
追问
试过了,也不行。
追答
为什么不直接使用oimage.Save方法?还需要转换成BMP
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private void ZoomPic(HttpContext context, System.Drawing.Image oimage, int desWidth, int desHeight)
{
Bitmap bmp = new Bitmap(oimage);
Graphics g = Graphics.FromImage(bmp);
bmp.Save(context.Response.OutputStream, ImageFormat.Jpeg);
bmp.Dispose();
}
希望能帮到你。
更多追问追答
追问
没用,还是现实不出图片。
追答
把你的代码发到我邮箱 我给你看下。245002754
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询