Drawing to Bitmap basis .GDI

1, from: WPF how to quickly draw a lot of graphics, such as 100,000 lines? -CSDN Forum .html ( https://bbs.csdn.net/topics/391042368?list=982381 )

     
        Bitmap m_bmp;
        Graphics g;
        Random ran = new Random(System.DateTime.Now.Millisecond);
        private void button1_Click(object sender, EventArgs e)
        {
            long cur = System.DateTime.Now.Ticks;

            m_bmp = new Bitmap(400, 300);
             g = Graphics.FromImage(m_bmp);
            Pen p = new Pen(Color.Red,1);
     
            for (int i = 0; i < 100000;i++ )
            {
                double x = ran.NextDouble() * 400;
                double y = ran.NextDouble() * 300;
                g.DrawLine(p, new Point((int)x, (int)y), new Point(100, 100));

            }
            this.CreateGraphics().DrawImage(m_bmp,0,0);
            double time2 = (System.DateTime.Now.Ticks - cur) / (10000d * 1000);

        }

 

2、

3、

4、

5、

 

Guess you like

Origin www.cnblogs.com/csskill/p/11583243.html