没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
protected void Page_Load(object sender, EventArgs e)
{
string valueStr = "";
int fontsize = 20;
int count = 5;
int fwidth = -2;//字体间的距离
int width = (fontsize + fwidth) * count + 5;
int height = fontsize + 6;
Font f;
Random r = new Random();
string vs = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
string fs = "宋体,新宋体,仿宋_GB2312,黑体,楷体_GB2312";
Color[] cs = new Color[] { Color.White, Color.White, Color.Yellow };
System.Drawing.Image bitmap = new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
//System.Drawing.Image bitmap = new System.Drawing.Bitmap(width, height);//不透明
Graphics graphics = Graphics.FromImage(bitmap);
//graphics.Clear(Color.FromArgb(60, 107, 139));//不透明
graphics.Clear(Color.Transparent);
for (int i = 0; i < count; i++)
{
string cha = vs.Substring(r.Next(vs.Length - 1), 1);
valueStr += cha;
f = new Font(fs.Split(',')[r.Next(fs.Split(',').Length)], fontsize, FontStyle.Bold);
graphics.DrawString(cha, f, new SolidBrush(cs[r.Next(cs.Length)]), new PointF(i * (fontsize + fwidth), 0));
}
Session.Add("validatStr", valueStr);
{
string valueStr = "";
int fontsize = 20;
int count = 5;
int fwidth = -2;//字体间的距离
int width = (fontsize + fwidth) * count + 5;
int height = fontsize + 6;
Font f;
Random r = new Random();
string vs = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
string fs = "宋体,新宋体,仿宋_GB2312,黑体,楷体_GB2312";
Color[] cs = new Color[] { Color.White, Color.White, Color.Yellow };
System.Drawing.Image bitmap = new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
//System.Drawing.Image bitmap = new System.Drawing.Bitmap(width, height);//不透明
Graphics graphics = Graphics.FromImage(bitmap);
//graphics.Clear(Color.FromArgb(60, 107, 139));//不透明
graphics.Clear(Color.Transparent);
for (int i = 0; i < count; i++)
{
string cha = vs.Substring(r.Next(vs.Length - 1), 1);
valueStr += cha;
f = new Font(fs.Split(',')[r.Next(fs.Split(',').Length)], fontsize, FontStyle.Bold);
graphics.DrawString(cha, f, new SolidBrush(cs[r.Next(cs.Length)]), new PointF(i * (fontsize + fwidth), 0));
}
Session.Add("validatStr", valueStr);
资源评论
- ynsunrise2013-10-21出现了很多错误,真郁闷
- xiaoyang26262013-11-22可以用 如果追求完美还需自己小改一下
- 岸边鱼2013-12-10谢谢,我是初学,不过有点错误!!!
- enkyou2015-10-21一片乱码,我日
- anniky52014-04-22不错,如果用在项目中 需要修改。
hzaccp3
- 粉丝: 14
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功