您的位置:首页 > 编程语言 > C#

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

2015-06-12 17:19 901 查看
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# 缓冲