1. 我先在Paint 把 所有要画的内容画到 m_bmpBackLine01;//Bitmap m_bmpBackLine01
2. this.CreateGraphics().DrawImage(m_bmpBackLine01, 15, 0);//画到form上
3. 定时器1000ms 定时刷新 调用 this.Invalidate();结果闪烁很厉害,添加了
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);还是一样 感觉更严重一些. 图的整个屏幕.
2. this.CreateGraphics().DrawImage(m_bmpBackLine01, 15, 0);//画到form上
3. 定时器1000ms 定时刷新 调用 this.Invalidate();结果闪烁很厉害,添加了
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);还是一样 感觉更严重一些. 图的整个屏幕.
用PictureBox吧,直接在上面画就行,把它的属性设置一下就不闪烁了
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.ResizeRedraw, true); 使用上面的设置后,不能通过this.CreateGraphics()来建立Graphics对象,而是通过OnPaint方法或paint事件里的e.Graphics
来绘制图像,否则没有效果或效果不明显。
例如:
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage(m_bmpBackLine01, 15, 0);//画到form上
base.OnPaint(e);
}
--------------------------------------------------------------
你自己画的时候,虽然有设置了双缓冲属性,但还是直接在上面画的,所以还有一种双缓冲是在内存中画好的时候再贴出来,我想PictureBox应该也是这样来做的