是否可以使用 Response.Write/WriteFile 从动态创建的位图写入 http 响应流,而不将图像保存到硬盘驱动器?
您可以使用MemoryStream并将其分配给Response.OutputStream,或者简单地使用Response.OutputStream
保存位图时直接。
文档中有一个示例this页,尽管它只是将位图直接保存到输出流:
// Set the correct content type, so browser/client knows what you are sending
Response.ContentType = "image/jpeg";
Response.Clear();
Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bmp);
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)