会员: 密码:  免费注册 | 忘记密码 | 会员登录 网页功能: 加入收藏 设为首页 网站搜索  
 安全技术技术文档
  · 安全配制
  · 工具介绍
  · 黑客教学
  · 防火墙
  · 漏洞分析
  · 破解专题
  · 黑客编程
  · 入侵检测
 安全技术论坛
  · 安全配制
  · 工具介绍
  · 防火墙
  · 黑客入侵
  · 漏洞检测
  · 破解方法
  · 杀毒专区
 安全技术工具下载
  · 扫描工具
  · 攻击程序
  · 后门木马
  · 拒绝服务
  · 口令破解
  · 代理程序
  · 防火墙
  · 加密解密
  · 入侵检测
  · 攻防演示
技术文档 > Web开发 > ASP.Net
ASP.NET中制作图形
发表日期:2003-07-02 00:00:00作者: 出处:  

  这个程序经过修改 现在作计数器的话 只能做黑白的 计数器,谁有办法 能够做出 复杂的 图形计数器?

<% @Page Language="C#" %>

<% @Import Namespace="System.Drawing" %>

<% @Import Namespace="System.IO" %>

<% @Import Namespace="System.Drawing.Imaging" %>

<%

Response.Expires = 0;

Bitmap newBitmap = null;

Graphics g = null ;

string str2Render = Request.QueryString.Get("HitCount");

if (null == str2Render) str2Render = "12345";

string strFont = Request.QueryString.Get("HitFontName");

if (null == strFont) strFont = "楷体_GB2312";

int nFontSize = 12;

try

{

nFontSize = Request.QueryString.Get("HitFontSize").ToInt32();

}

catch

{

// do nothing, just ignore

}

string strBackgroundColorname = Request.QueryString.Get("HitBackgroundColor");

Color clrBackground = Color.White;

try

{

if (null != strBackgroundColorname)

clrBackground = ColorTranslator.FromHTML(strBackgroundColorname);

}

catch

{

}

string strFontColorName = Request.QueryString.Get("HitFontColor");

Color clrFont = Color.Black;

try

{

// Format in the URL: %23xxXXxx

if (null != strFontColorName)

clrFont = ColorTranslator.FromHTML(strFontColorName);

}

catch

{

}

try

{

Font fontCounter = new Font(strFont, nFontSize);

newBitmap = new Bitmap(1,1,PixelFormat.Format32bppARGB);

g = Graphics.FromImage(newBitmap);

SizeF stringSize = g.MeasureString(str2Render, fontCounter);

int nWidth = (int)stringSize.Width;

int nHeight = (int)stringSize.Height;

g.Dispose();

newBitmap.Dispose();

newBitmap = new Bitmap(nWidth,nHeight,PixelFormat.Format32bppARGB);

g = Graphics.FromImage(newBitmap);

g.FillRectangle(new SolidBrush(clrBackground), new Rectangle(0,0,nWidth,nHeight));

g.DrawString(str2Render, fontCounter, new SolidBrush(clrFont), 0, 0);

MemoryStream tempStream = new MemoryStream();

newBitmap.Save(tempStream,ImageFormat.GIF);

Response.ClearContent();

Response.ContentType = "image/GIF";

Response.BinaryWrite(tempStream.ToArray());

Response.End();

}

catch (Exception e)

{

Response.Write(e.ToString());

}

finally

{

if (null != g) g.Dispose();

if (null != newBitmap) newBitmap.Dispose();

}

%>

返回顶部】 【打印本页】 【关闭窗口

关于我们 / 给我留言 / 版权举报 / 意见建议 / 网站编程QQ群   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net 加载时间 0.00168