private void pictureBox1_Click(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(120, 80);
Graphics g = Graphics.FromImage(bmp);
Random r = new Random();
string str = "";
for (int i = 0; i < 5; i++)
{
int rNum = r.Next(0, 10);
str += rNum;
}
InstalledFontCollection fonts = new InstalledFontCollection();
FontFamily[] fs = fonts.Families;
for (int i = 0; i < 5; i++)
{
Point p=new Point(i*20,0);
g.DrawString(str[i].ToString(),new Font(fs[i],20,FontStyle.Bold),new SolidBrush(colors[i]),p);
}
for (int i = 0; i < 20; 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.Pink), p1, p2);
}
for (int i = 0; i < 20; i++)
{
bmp.SetPixel(r.Next(0, bmp.Width), r.Next(0, bmp.Height), Color.Black);
}
pictureBox1.Image = bmp;
//MessageBox.Show(str);
}
}