ASP.net图像处理和添加此图片图像控制 [英] ASP.net image processing and adding this image to Image control
问题描述
我有以下的code:
bmp = new Bitmap("C:\\resim.jpg");
Graphics g = Graphics.FromImage(bmp);
g.DrawString(metin, new Font(metin, 9, FontStyle.Regular), new SolidBrush(System.Drawing.Color.Black), 10, 10);
有了这个code,我可以创造一个新的形象。现在,我将展示我的形象在我的网页上即我将展示与图像控制它。我该怎么办?
With this code I can create a new image. Now I will be showing my image on my web page i.e I will be showing it with Image control. What can I do?
推荐答案
如果您保存到你不必担心产生不同的临时文件为每个图像和清理,当你完成磁盘。它可能会更好,以实现动态生成图像,并将其写回一个IHttpHandler的。当然,你还需要一些附加的网址,让你知道写什么文字,但没有后来的垃圾进行清理。
If you save it to disk you have to worry about generating a different temp file for each image and cleaning up when your done. It's probably better to implement an IHttpHandler that generates the image on the fly and writes it back. Of course you still need to append something to the url so that you know what text to write, but there's no garbage to clean up later.
所以,你会做这样的事情:
So you would do something like:
Image1.ImageUrl = "MyImageHandler.ashx?key=xyz";
,你会建立一个映射在你的web.config发送的请求MyImageHandler.ashx你的实现类。
and you would set up a mapping in your web.config to send requests for MyImageHandler.ashx to your implementing class.
这篇关于ASP.net图像处理和添加此图片图像控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!