本文实例讲述了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#程序设计有所帮助。
您可能感兴趣的文章:C#双缓冲实现方法(可防止闪屏)C#默认双缓冲技术实例分析C#词法分析器之输入缓冲和代码定位的应用分析C#读取中文字符及清空缓冲区的实现代码C#自定义缓存封装类实例C# Memcached缓存用法实例详解C#中缓存的基本用法总结c#自带缓存使用方法 c#移除清理缓存asp.net(C#)遍历memcached缓存对象C#双缓冲技术实例详解