62,266
社区成员
发帖
与我相关
我的任务
分享
//额,你画完没有让它在浏览器显示啊,加上那两句!
g.DrawLines(Blp, p);
img.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.ContentType = "image/jpeg";
g.Dispose();
img.Dispose();

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<img src="Default2.aspx" alt="简单折线图" />
</div>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
this.pic();
}
protected void pic()
{
float[] shuzu = new float[] { 0f, 0.6328f, 1f };
float[] shuzu2 = new float[] { 0f, 0, 4923f, 1f };
int m = shuzu.Length;
int[] shuzuint = new int[m];
int[] shuzuint2 = new int[m];
for (int i = 0; i < m; i++)
{
shuzuint[i] = (int)(shuzu[i] * 300);
shuzuint2[i] = (int)(shuzu2[i] * 300);
}
Bitmap img = new Bitmap(400, 400);
Graphics g = Graphics.FromImage(img);
g.Clear(Color.Blue);
Pen Blp = new Pen(Color.Blue);
Pen Bp = new Pen(Color.Black);
Pen Rp = new Pen(Color.Red);
Pen Sp = new Pen(Color.Silver);
g.DrawRectangle(Bp, 0, 0, img.Width - 1, img.Height - 1);
g.DrawLine(Bp, 10, 10, 10, 310);
g.DrawLine(Bp, 10, 310, 310, 310);
Point[] p = new Point[m];
for (int i = 0; i < m; i++)
{
p[i].X = 10 + shuzuint[i];
p[i].Y = 310 - shuzuint2[i];
}
g.DrawLines(Blp, p);
img.Save(Response.OutputStream, ImageFormat.Gif);
Response.ContentType = "img/gif";
Response.Flush();
Response.End();
g.Dispose();
img.Dispose();
}