(转载)GDI+双缓冲

 双缓冲在GDI+里可以有效的提高描画效率。改善显示的质量。

  下面的代码是一个最简单的双缓冲的模板。可以根据需要,做简单的修改即可。

      Bitmap CacheImage( [Width], [Height] );
      Graphics CacheGraphics( &CacheImage );
 
      // 对CacheImage进行描画
      // ......
      
      // 获得窗口的Graphics对象
      Graphics Graphic( [ Window’s HDC ] );
 
// 将描画好的CacheImage画到窗口上
      Graphic.DrawImage( &CacheImage, [Left], [Top] );

 
根据一些简单的测试,双缓冲可以有效的改善图像的处理速度。不过最明显的效果还是降低画面的闪烁程度。

另外还可以使用CachedBitmap类来做双缓冲。Graphic也有专门的DrawCachedBitmap方法来描画CachedBitmap。但没有上述的方法灵活。

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/eplanet/archive/2007/10/12/1821239.aspx

posted @ 2013-09-15 19:22  学友2000  阅读(275)  评论(0编辑  收藏  举报