是否可以使用Response.Write/WriteFile从动态创建的位图写入http响应流而不将图像保存到硬盘驱动器?
Ode*_*ded 11
您可以使用a MemoryStream并将其指定给Response.OutputStream,或者Response.OutputStream在保存位图时直接使用.
此页面上的文档中有一个示例,但它只是将位图直接保存到输出流:
// 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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5025 次 |
| 最近记录: |