Vanish.

要怎样努力,才能成为很厉害的人?

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

private void CheckIdentifyingCode() {
Random r = new Random();
string str = "";
for (int i = 0; i < 5; i++)
{
int a = r.Next(0, 10);
str += a;//将数字连接到一块
}

Bitmap bm = new Bitmap(150, 90);//创建位图对象
Graphics g = Graphics.FromImage(bm);//在bm中重新画图

//创建字体跟颜色数组
string[] font = { "楷体", "黑体", "宋体", "斜体", "新宋体" };
Color[] colors = { Color.Red, Color.Blue, Color.Green, Color.Yellow, Color.YellowGreen };

//开始画图

for (int i = 0; i < 5; i++)
{
Point p = new Point(i * 20, 0);
g.DrawString(str[i].ToString(), new Font(font[i], 20, FontStyle.Bold), new SolidBrush(colors[i]), p);
}
pictureBox1.Image = bm;//将位图显示到picture上
}

posted on 2015-04-27 16:58  Vanish.  阅读(826)  评论(0编辑  收藏  举报