在将图片以 PNG 格式保存至 Response.OutputStream 时,会碰到如下错误:

GDI+ 中发生一般性错误。

原因:

在写 PNG 格式的图像时,指针需要在存储的位置来回移动。而 Response.OutputStream 只支持顺序访问。

解决方案:

先将 PNG 格式的图像保存至内存(内存总是可以随机访问的,即指针可以在内存中的存储位置来回移动),再将内存的存储内容复制写入 Response.OutputStream 中。

转载:http://www.zizhujy.com/blog/post/2011/07/25/general-error-occured-in-gdiplus-problem-with-saving-png-image-to-outputstream.aspx

04-16 01:14