标签:
private void pictureBox1_Click(object sender, EventArgs e) { Random r = new Random(); string str = null; for (int i = 0; i < 6; i++) { int rnumber = r.Next(0, 10); str += rnumber; } //创建GDI对象 Bitmap bmp = new Bitmap(120, 25); Graphics g = Graphics.FromImage(bmp); for (int i = 0; i < 6; i++) { Point p = new Point(i * 15, 0); string[] Fonts = { "隶书", "仿宋", "华文行楷", "宋体", "微软雅黑" }; Color[] colors = { Color.Red, Color.Black, Color.Blue, Color.DeepPink, Color.DimGray }; g.DrawString(str[i].ToString(), new Font(Fonts[r.Next(0, 5)], 15, FontStyle.Bold), 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(Brushes.Green), p1, p2); } for (int i = 0; i <= 200; 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)); bmp.SetPixel(p1.X,p1.Y,Color.Black); } pictureBox1.Image = bmp; }
标签:
原文地址:http://www.cnblogs.com/-slient/p/5116609.html