我对此很陌生。下面的代码是我在我的用户控件中的,但是当我将它插入到.aspx页面时,图像会占据整个页面并删除其他现有的控件。如何在.aspx页面中的指定给usercontrol的div内显示包含图形(g)的图像,而不删除所有其他控件?由于如何在用户控件的aspx页面上显示图像,而不占用整个页面?
DisplayImage.aspx(用户控制)
Bitmap BitMapImage= new System.Drawing.Bitmap(Server.MapPath("image1.Png"));
Graphics g= Graphics.FromImage(BitMapImage);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.DrawString("GREAT", new Font("Calibri", 18,FontStyle.Bold), SystemBrushes.WindowText, new Point(175, 300));
Response.ContentType="image/Png";
BitMapImage.Save(Response.OutputStream, ImageFormat.Png);
所以基本上我必须先将它存储到一个文件夹然后从那里读取它? – Seesharp 2012-02-18 02:49:00
图像不一定是物理文件;您可以从一个aspx文件动态生成它 - 只需使用''标签从HTML中引用图像生成aspx文件即可。 – RickNZ 2012-02-18 06:09:15
我必须首先将它制作为ashx文件,但是它的工作原理非常好,谢谢 – Seesharp 2012-02-18 11:46:57