All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
Asp.net,弹出对话框基类,(输出alet警告框)_[Asp.Net教程]
使用PHP的Socket写的POP3类_[PHP教程]
Visual,Studio,2008,简体中文版下载_[Asp.Net教程]
SQL Server 2005数据库升级技巧_[SQL Server教程]
WAP与PHP程序设计之基础篇_[PHP教程]
ASP.NET:写个偷全国公交数据库的程序_.net资料_编程技术
怎样在PHP,中运用,SimpleXML,处理任务_php资料_编程技术
利用PHP代码实现网页自动判断转向_[PHP教程]
深入剖析Asp.net资源文件_[Asp.Net教程]
ASP.NET,2.0高级数据处理之冲突检测_.net资料_编程技术
Reading number is top 10 pictures
The real super beauty7
陪睡门马睿菈自曝写真 称首拍大尺度照片3
The terra-cotta warriors3
29 the belle stars after bath figure1
Chinese paper-cut grilles art appreciation3
人美胸美腿更美3
2012 national geographic daily picture1
So beauty, will let you spray blood5
Absolutely shocked. National geographic 50 animal photographys7
This is heaven to some path
Download software ranking
Boxer's Top ten classic battle6
Tram sex maniac 2 (H) rar bag4
The Bermuda triangle3
Tram sex maniac 2 (H) rar bag14
The hero
C#COM编程指南
WebService在.NET中的实战应用教学视频 → 第4集
美女游泳记
Unix video tutorial18
Tram sex maniac 2 (H) rar bag11
归海一刀 published in(发表于) 2014/1/30 1:26:12 Edit(编辑)
c#生成图片验证码代码_[Asp.Net教程]

c#生成图片验证码代码_[Asp.Net教程]

c#生成图片验证码代码_[Asp.Net教程]

















前台引用.aspx:
































YanZhengCode.cs




















using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.IO;

public partial class YanZhengCode : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//string str = Request["chen"];
BuildCode();

//ShuImg();
}

private void BuildCode()

{

Color[] strcolor ={ Color.Red, Color.Blue, Color.Brown,Color.Black,Color.Tomato };

string[] strfont={"华文中宋"};
Random rands = new Random();
Bitmap images = new Bitmap(80,26); //图片大小
Graphics g = Graphics.FromImage(images);
Font f = new Font(strfont[0], 20); //字体大小

//笔刷填充色
Brush b = new SolidBrush(Color.Tomato);
Brush b2 = new SolidBrush(strcolor[rands.Next(0,strcolor.Length)]);
Brush b3 = new SolidBrush(Color.Red);
Brush b4 = new SolidBrush(Color.FromArgb(128,Color.Green));
g.Clear(Color.Wheat);

//线条颜色
Pen p = new Pen(Color.Red, 0);
Pen p2 = new Pen(Color.Turquoise,0);
Random rand = new Random();
for (int i = 0; i < 40; i++)
{
int y = rand.Next(images.Height);
int x = rand.Next(images.Width);
//g.DrawLine(p, 0, y, images.Width, y);
g.DrawRectangle(p2, x, y, 1, 1);
}
//int degree = 5;
//Point tempPoint = new Point();
//degree = ~degree + 1;
//g.RotateTransform(degree);
//tempPoint.X = 20;
//tempPoint.Y = 4;

g.DrawRectangle(p, 0, 0, images.Width-1, images.Height-1); //绘图区域
string strCode = rand.Next(1000,10000).ToString();
Session["yanzhencode"] = strCode;
g.DrawString(strCode.Substring(0, 1), f, b, 2,-1);
g.DrawString(strCode.Substring(1, 1), f, b2, 19, -1);
g.DrawString(strCode.Substring(2, 1), f, b3, 37, -1);
g.DrawString(strCode.Substring(3, 1), f, b4, 50, -1);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
images.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.ClearContent();
Response.ContentType = "image/jpeg";
Response.BinaryWrite(ms.ToArray());
//Response.Cookies.Add(new HttpCookie("chne", "6780"));
g.Dispose();
images.Dispose();
}

private void ShuImg()
{
Response.ContentType = "image/*"; //设置发送头为图像数据
Response.Clear(); //清空发送数据
Random rand = new Random();
Stream stream = OpenFile(Server.MapPath("pic/"+rand.Next(1,6).ToString()+".jpg")); //打开文件流
Bitmap bit = new Bitmap(stream);
bit.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到输出流中
stream.Close();
bit.Dispose();
Response.Flush(); //输出到客户端
}
}








































添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.