Response.WriteFile - 写出字节流 [英] Response.WriteFile -- Write out a byte stream
本文介绍了Response.WriteFile - 写出字节流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
时可以写入到从使用的Response.Write / WriteFile的动态创建位图的HTTP响应流无图像保存到硬盘驱动器?
Is is possible to write to the http response stream from a dynamically created bitmap using the Response.Write/WriteFile without saving the image to the hard drive?
推荐答案
您可以使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.io.memorystream.aspx\"><$c$c>MemoryStream$c$c>并指定为<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.htt$p$psponse.outputstream.aspx\"><$c$c>Response.OutputStream$c$c>,或者干脆保存位图时,使用 Response.OutputStream
直接
There is an example in the documentation on this page, though it simply saves the bitmap directly to the output stream:
// 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);
这篇关于Response.WriteFile - 写出字节流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文