双缓存处理图片等

 private void Form1_Paint(object sender, PaintEventArgs e)
        {
            BufferedGraphics bg;
            Graphics g;
            BufferedGraphicsContext bc = BufferedGraphicsManager.Current;
            bg = bc.Allocate(this.CreateGraphics(), this.DisplayRectangle);//Graphics存入缓存区
            g = bg.Graphics;//得到缓存区的Graphics
            Pen p = new Pen(Color.Red);
            p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
            p.Width = 2;
            g.DrawLine(p, 10, 10, 200, 10);
            bg.Render();//复制出缓存区并呈现出来
            bg.Dispose();
            p.Dispose();

 

posted on 2012-10-20 16:22  R.Ray  阅读(127)  评论(0)    收藏  举报

导航