C#Winform Graphics方法DrawLine画图问题

        Bitmap bp = new Bitmap(400, 400);
        Graphics g = Graphics.FromImage(bp);
        g.Clear(Color.White);
        for (int i = 0; i < 25; i++)
        {
            Random r = new Random();
            int r1 = r.Next(bp.Width);
            int r2 = r.Next(bp.Width);
            int h1 = r.Next(bp.Height);
            int h2 = r.Next(bp.Height);
            Pen p = new Pen(Color.Silver);
            g.DrawLine(p, r1, h1, r2, h2);

        }
        pictureBox1.Image = (Image)bp;

循环只执行了一次,断点时 或在循环中加入Thread.Sleep(10)方法可完全执行

查看全部
wcj_me
wcj_me
2015/07/15 08:57
  • c#
  • raphics
  • bitmap
  • 点赞
  • 收藏
  • 回答
    私信

3个回复