欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#手工双缓冲技术用法实例分析

程序员文章站 2023-11-24 19:14:46
本文实例讲述了c#手工双缓冲技术。分享给大家供大家参考。具体如下: using system; using system.collections.generic...

本文实例讲述了c#手工双缓冲技术。分享给大家供大家参考。具体如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
namespace advanced_drawing
{
  public partial class form19 : form
  {
    bufferedgraphicscontext buffercontext;
    bitmap gif = new bitmap(@"d:/我的文档/桌面/ico/a.gif");
    public form19()
    {
      initializecomponent();
      buffercontext = new bufferedgraphicscontext();
      buffercontext.maximumbuffer = this.clientrectangle.size;
    }
    void gif_framechanged(object sender, eventargs e)
    {
      graphics g = this.creategraphics();
      bufferedgraphics frame = buffercontext.allocate(g, this.clientrectangle);
      imageanimator.updateframes(gif);
      frame.graphics.drawimage(gif, this.clientrectangle);
      frame.render();
    }
    private void form19_formclosing(object sender, formclosingeventargs e)
    {
      buffercontext.dispose();
    }
    private void form19_paint(object sender, painteventargs e)
    {
      if (imageanimator.cananimate(gif))
      {
        imageanimator.animate(gif, gif_framechanged);
      }
    }
  }
}

希望本文所述对大家的c#程序设计有所帮助。