这里是FrmMain.aspx界面
<%@ Page language="c#" Debug="true" CodeFile="FrmMain.aspx.cs" AutoEventWireup="false" Inherits="Web_Test.FrmMain" %>
这里是FrmMain.aspx.cs代码
FrmMain.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.ComponentModel;
using System.Web.Security;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;//文件存取
using System.Drawing;//画图基本功能
using System.Drawing.Drawing2D;//二维画图
using System.Drawing.Imaging;//高级功能
namespace Web_Test
{
partial class FrmMain : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
Bitmap img = new Bitmap(400, 200);//创建Bitmap对象
MemoryStream stream = draw();
img.Save(stream, ImageFormat.Jpeg); //保存绘制的图片
Response.Clear();
Response.ContentType = "image/jpeg";
Response.BinaryWrite(stream.ToArray());
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public MemoryStream draw()
{
Bitmap img = new Bitmap(1000, 800);//创建Bitmap对象
Graphics g = Graphics.FromImage(img);//创建Graphics对象
Pen Bp = new Pen(Color.Black); //定义黑色画笔
Pen Rp = new Pen(Color.Red);//红色画笔
Pen Sp = new Pen(Color.Blue);//蓝色
AdjustableArrowCap aac; //定义箭头帽
aac = new System.Drawing.Drawing2D.AdjustableArrowCap(4, 4);
Sp.CustomStartCap = aac; //开始端箭头帽
Font Bfont = new Font("Arial", 12, FontStyle.Bold);//大标题字体
Font font = new Font("Arial", 18);//一般字
Font Tfont = new Font("Arial", 9);//较大字体
g.DrawRectangle(new Pen(Color.White, 800), 0, 0, img.Width, img.Height); //矩形 底色
Line
arGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Black, Color.Black, 1.2F, true);
LinearGradientBrush Bluebrush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Blue, Color.Blue, 1.2F, true);
g.DrawLine(Sp, 50, 50, 50, 500);//数坐标
g.DrawLine(Sp, 1000, 500, 50, 500);//横坐标
g.DrawLine(Sp, 50, 1000, 50, 500);//数坐标
g.DrawString("y=X/lnX 0
g.DrawString("y=X/lnX 1 double x;
double y;
double z;
for (x=1.001;x <25;x+=0.001)
{
y= x/Math.Log(x);
g.DrawLine(Rp,new Point((int)(50*x)+50,500-(int)(y* 50)),new Point((int)(x*50)+51,500-(int)(y* 50)));
}
for (x=0.001;x <1;x+=0.001)
{
y= x/Math.Log(x);
g.DrawLine(Rp,new Point((int)(50*x)+50,500-(int)(y* 50)),new Point((int)(x*50)+51,500-(int)(y* 50)));
}
MemoryStream stream = new MemoryStream(); //保存绘制的图片
img.Save(stream, ImageFormat.Jpeg); //保存绘制的图片
return stream;
}
}
}
上一篇:asp[1]net(c#)+base64编码处理类_net代码
下一篇:重庆交通大学机电与汽车工程学院毕业设计(论文)工作规范修订20140430