//通过一个循环 像图片中画入文本
for (int i = 0; i < 5; i++)
{
Point p = new Point(i * 20, 0);
g.DrawString(str[i].ToString(), new Font(family[r.Next(0,family.Length)], 15), new SolidBrush(colors[r.Next(0,5)]), p);
}
//给图片中画一些直线
for (int i = 0; i < 15; i++)
{
Point p1 = new Point(r.Next(0, bmp.Width), r.Next(0, bmp.Height));
Point p2 = new Point(r.Next(0, bmp.Width), r.Next(0, bmp.Height));
g.DrawLine(new Pen(Color.Black), p1, p2);
}
////给验证码中加入像素颗粒
for (int i = 0; i < 100; i++)
{
Point p1 = new Point(r.Next(0, bmp.Width), r.Next(0, bmp.Height));
bmp.SetPixel(p1.X, p1.Y, Color.Blue);
}