用C#在window应用程序上怎么写验证码?
2个回答
展开全部
Bitmap img = new Bitmap(80,35);
Graphics g = Graphics.FromImage(img);
g.Clear(Color.White);
g.DrawRectangle(new Pen(Color.Red,2), new Rectangle(0,0,img.Width,img.Height));
for (int i = 0; i < 50; i++)
{
int x = new Random().Next(img.Width);
int y = new Random().Next(img.Height);
img.SetPixel(x, y,Color.Blue);
}
for (int i = 0; i < 2; i++)
{
int x = new Random().Next(100);
int y = new Random().Next(100);
int x1 = new Random().Next(100);
int y1 = new Random().Next(100);
g.DrawLine(new Pen(Color.Silver),new Point(x,y),new Point(x1,y1));
}
string code = "";
string pp = "abcdefghijklmnopqrstuvwxyz1234567890";
for (int i = 0; i < 4; i++)
{
code+=pp[new Random().Next(pp.Length)];
}
g.DrawString(code,new Font("宋体",20),Brushes.Black,new PointF(1,1));
pictureBox1.Image = img;
Graphics g = Graphics.FromImage(img);
g.Clear(Color.White);
g.DrawRectangle(new Pen(Color.Red,2), new Rectangle(0,0,img.Width,img.Height));
for (int i = 0; i < 50; i++)
{
int x = new Random().Next(img.Width);
int y = new Random().Next(img.Height);
img.SetPixel(x, y,Color.Blue);
}
for (int i = 0; i < 2; i++)
{
int x = new Random().Next(100);
int y = new Random().Next(100);
int x1 = new Random().Next(100);
int y1 = new Random().Next(100);
g.DrawLine(new Pen(Color.Silver),new Point(x,y),new Point(x1,y1));
}
string code = "";
string pp = "abcdefghijklmnopqrstuvwxyz1234567890";
for (int i = 0; i < 4; i++)
{
code+=pp[new Random().Next(pp.Length)];
}
g.DrawString(code,new Font("宋体",20),Brushes.Black,new PointF(1,1));
pictureBox1.Image = img;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询