简体   繁体   English

如何在ASP.NET中即时生成图像

[英]How to generate images on the fly in ASP.NET

As the title says, how can generate (and display) images on the fly for simple charting, resizing etc? 如标题所述,如何动态生成(显示)图像以进行简单的制图,调整大小等?

Thanks 谢谢

Use System.Drawing namespace. 使用System.Drawing命名空间。

Add a reference to System.Drawing assembly. 添加对System.Drawing程序集的引用。 Create a new Bitmap class. 创建一个新的Bitmap类。 Call CreateGraphics on it. 在其上调用CreateGraphics Use the returned Graphics object to do your drawing. 使用返回的Graphics对象进行绘制。 Set the Response.ContentType to the appropriate image MIME type. Response.ContentType设置为适当的图像MIME类型。 Finally save the Bitmap to the Response.Output stream. 最后,将Bitmap保存到Response.Output流。

检查有关System.Drawing和ASP.NET的警告。http: //msdn.microsoft.com/zh-cn/library/system.drawing.aspx如果现在正在使用,请使用WPF http:// www。 codeproject.com/KB/WPF/WPF-Image-to-WebPage.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM