日期:2014-05-18  浏览次数:21048 次

c#关于picturebox的闪烁和效率问题
大虾们好,我想问一个问题 ,我现在希望picturebox在我时钟中断(200ms)的时候 每次都更新图片 (我利用的是双缓冲,在时钟中断的时候将内存中的图片显示在显示器上),但是我发现picturebox 不能自动清除原来的内容,这样就有很多以前图片的遗留下来的效果。我试图清空picturebox,在网上查到可以用this.Picturebox1.Image=null; 我试了一下 发现可以是可以 但是闪烁的太厉害了(因为我是放在时钟中断里面) 请问一下 大家有什么好办法吗??谢谢啦 


ps:用了 this.Picturebox.Image.Dispose(),后this.Picturebox1.Image=null,仍然没有解决闪烁的问题;而且,我直接在form上画还是闪烁的很厉害

帮帮忙啊~~~很急~~~谢谢~~~

------解决方案--------------------
把双重缓冲=true

先定义一个Bitmap,然后在这个Bitmap上进行图像的绘制 
最后再将这个Bitmap绘制在你的PictureBox上 

如:dim bmp as new Bitmap(picturebox1.width,picturebox1.height) 
dim g as graphics=graphics.fromImage(bm) 
g.drawrectangle(……) 
g.drawrectangle(……) 
…… 
g=pictureBox1.createGraphics 
g.drawimage(bmp,0,0)

------解决方案--------------------
Form.DoubleBuffer = true;
------解决方案--------------------
帮顶


------解决方案--------------------
学习。up.