GDI +中发生一般性错误。而保存图像 [英] a generic error occurred in gdi+. while saving an image

查看:143
本文介绍了GDI +中发生一般性错误。而保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的专家为什么我在保存图像的code是如下:

Dear Expert i am getting an error while saving an image the code is as follows

  ClsImageManager objImgManager = new ClsImageManager();
  Bitmap ImageBitmap = objImgManager.GetBitmapFromBytes(ImageData);
  Response.ContentType = "image/tiff";
  ImageBitmap.Save(Response.OutputStream, ImageFormat.Tiff);
  ImageBitmap.Dispose();
  Response.End();

当我用Image.format.jpeg的code工作很好,但是当我把它变为ImageFormat.Tiff然后我得到一个错误的 GDI +中发生一般性错误。

推荐答案

您应该注意的是GDI / GDI +(System.Drawing中命名空间的)没有正式ASP支持。 NET - 见注意事项中 http://msdn.microsoft.com/ EN-US /库/ system.drawing.aspx 。结果
WIC应该被用来代替的GDI(参见<一href=\"http://weblogs.asp.net/bleroy/archive/2009/12/10/resizing-images-from-the-server-using-wpf-wic-instead-of-gdi.aspx\" rel=\"nofollow\">http://weblogs.asp.net/bleroy/archive/2009/12/10/resizing-images-from-the-server-using-wpf-wic-instead-of-gdi.aspx)

You should note that GDI/GDI+ (System.Drawing namespace) is not officially supported in ASP.NET - see "Caution" in http://msdn.microsoft.com/en-us/library/system.drawing.aspx.
WIC is supposed to be used instead GDI+ (see http://weblogs.asp.net/bleroy/archive/2009/12/10/resizing-images-from-the-server-using-wpf-wic-instead-of-gdi.aspx)

说,许多人成功地使用GDI +在ASP.NET中。最可能的是,你应该尝试保存图像到内存流(或文件),然后写入图像保存到响应。请参阅此链接了解详细信息:<一href=\"http://www.west-wind.com/weblog/posts/2006/Oct/19/Common-Problems-with-rendering-Bitmaps-into-ASPNET-OutputStream\" rel=\"nofollow\">http://www.west-wind.com/weblog/posts/2006/Oct/19/Common-Problems-with-rendering-Bitmaps-into-ASPNET-OutputStream

Said that, many had successfully use GDI+ in ASP.NET. Most probably, you should attempt saving image into memory stream (or on file) and then writing saved image into the response. See this link for details: http://www.west-wind.com/weblog/posts/2006/Oct/19/Common-Problems-with-rendering-Bitmaps-into-ASPNET-OutputStream

另一个变通可以与用户帐户。显然,GDI / GDI +绑定到设备上下文(屏幕,打印机等),他们可能不会在服务帐户可用。所以,你可以尝试一些普通用户帐户运行你的ASP.NET code是否有帮助或没有。

Another work-around can be related to user account. Apparently, GDI/GDI+ is bound to device context (screen, printer etc) and they may not be available under service accounts. So you may try running your ASP.NET code on some normal user account if that helps or not.

这篇关于GDI +中发生一般性错误。而保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆