请问如何在内存中生成一张图片并赋到网页上传给客户机上的网页? 主要请教如何在内存中生成图片和赋给网页传到客户机的浏览器上谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 建个网页<%@ Page language="c#" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML> <HEAD> <title></title> <script runat="server"> private string RndCode() { int code = (int)(new Random().NextDouble() * 10000); return code.ToString("0000"); } private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 System.Drawing.Image image = new System.Drawing.Bitmap(45,20); System.Drawing.Graphics formGraphice = System.Drawing.Graphics.FromImage(image); string code = RndCode(); System.Drawing.Font font = new System.Drawing.Font("Arial",12); System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); formGraphice.Clear(System.Drawing.Color.White); System.Drawing.StringFormat format = new System.Drawing.StringFormat(); formGraphice.DrawString(code,font,brush,0,00,format); font.Dispose(); brush.Dispose(); formGraphice.Dispose(); image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); } </script> <META http-equiv="Content-Type" content="image/jpeg"> <meta content="Microsoft Visual Studio 7.0" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="JavaScript (ECMAScript)" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> <LINK href="Forum.css" type="text/css" rel="stylesheet"> </HEAD> <body topMargin="0"> <form id="Form1" method="post" runat="server"> <FONT face="宋体"></FONT> </form> </body></HTML> System.Drawing空间是处理图片的用这个写到客户端:Response.BinaryWrite 谢谢: hzw66(超越理想) 我试下去 使用SizeChanged事件时,最小化托盘问题 提示说二维数组的索引超出数组的最大下标,找不原因,请高手指点一下啊,谢谢了? 如何获取远程计算机时间 关于sniffer嗅探器的设计(c#) 如何去掉窗体右上角的关闭按钮? 周六还上班的兄弟姐妹们辛苦了 求C#winform怎么实现在线搜索视频跟在线下载!请大神指教。 xml问题 C#里有没有Chr()? 为什么StreamWriter写LOG文件时,中文会乱码? 关于类库之间接口调用的问题,急! 如何设置编辑框,使其只能接受数字?
<%@ Page language="c#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title></title>
<script runat="server">
private string RndCode()
{
int code = (int)(new Random().NextDouble() * 10000);
return code.ToString("0000");
} private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
System.Drawing.Image image = new System.Drawing.Bitmap(45,20);
System.Drawing.Graphics formGraphice = System.Drawing.Graphics.FromImage(image);
string code = RndCode();
System.Drawing.Font font = new System.Drawing.Font("Arial",12);
System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
formGraphice.Clear(System.Drawing.Color.White);
System.Drawing.StringFormat format = new System.Drawing.StringFormat();
formGraphice.DrawString(code,font,brush,0,00,format);
font.Dispose();
brush.Dispose();
formGraphice.Dispose();
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
</script>
<META http-equiv="Content-Type" content="image/jpeg">
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript (ECMAScript)" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="Forum.css" type="text/css" rel="stylesheet">
</HEAD>
<body topMargin="0">
<form id="Form1" method="post" runat="server">
<FONT face="宋体"></FONT>
</form>
</body>
</HTML>
用这个写到客户端:
Response.BinaryWrite