chart.aspx
来自「电子选课系统 电子选课系统电子选课系统电子选课系统」· ASPX 代码 · 共 46 行
ASPX
46 行
<%@ Page Language="C#" %>
<%@import namespace="System.Drawing"%>
<%@import namespace="System.Drawing.Drawing2D"%>
<%@import namespace="System.Drawing.Imaging"%>
<%-- OutputCache Duration="60" VaryByParam="Length;Style"--%>
<script language="c#" runat="server">
readonly static Color[][] brushes=new Color[][]{
new Color[]{Color.FromArgb( 50 ,Color.Pink ),Color.FromArgb( 120 ,Color.Purple)},
new Color[]{Color.FromArgb( 50 ,Color.Purple ),Color.FromArgb( 120 ,Color.Pink)}
};
public void page_load(Object obj,EventArgs e)
{
int height = 16;
int style = 0;
int width = 20;
try{
string param = Request["Length"];
if (param==null||param.Equals("")) param="0";
width = int.Parse( param );
param = Request["Style"];
if (param==null||param.Equals("")) style=0;
else style = int.Parse( param );
}catch{}
if(style<0||style>=brushes.Length) return;
//创建一个bitmap实例
Bitmap bitmap=new Bitmap(width+1,height+1);
Graphics graphics=Graphics.FromImage(bitmap);
//画一个白色背景
graphics.FillRectangle(new SolidBrush(Color.White), 0, 0, width+1, height+1);
if(width==0) goto output;
//画一个矩形
Rectangle r = new Rectangle(1, 1, width, height);
LinearGradientBrush lb = new LinearGradientBrush(r, brushes[style][0], brushes[style][1], LinearGradientMode.Horizontal);
graphics.FillRectangle(lb, r);
//从网页输出
output:
Response.ContentType="image/jpeg";
bitmap.Save(Response.OutputStream,ImageFormat.Jpeg);
graphics.Dispose();
bitmap.Dispose();
}
</script>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?