使用Double-Buffer来实现无闪烁动态折线图

该博客介绍了如何利用GDI+的Double-Buffer技术绘制无闪烁的动态折线图。通过创建后台线程进行绘图操作,并在主线程中更新PictureBox,实现了平滑的动画效果。示例代码包括了线程同步、双缓冲图像的创建和更新等关键步骤。
摘要由CSDN通过智能技术生成

由于这片例子是借鉴于别人的基础上写的,我只是在上面加上了动态画折线图这部分,因为原理很简单,当时也只是为了给网友一个例子。没想到,还有很多人做这个,那么我就把这部分的代码贴出来,分享给大家。

 

大致代码如下:

//--------------------------- A Demo using Double-Buffer in GDI+ -------------------------------

//----------------------------------------------------------------------------------------------

//---File:          frmGraphView

//---Description:   A demo using double-buffer in GDI+

//---Author:        Knight

//---Date:          Jul.3, 2006

//----------------------------------------------------------------------------------------------

//---------------------------{A Demo using Double-Buffer in GDI+}-------------------------------

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

 

namespace GraphView

{

    using System.Threading;

 

    /// <summary>

    /// Summary description for Form1.

    /// </summary>

    public class frmGraphView : System.Windows.Forms.Form

    {

        private System.Windows.Forms.PictureBox picGraph;

        /// <summary>

        /// Required designer variable.

        /// </summary>

        private System.ComponentModel.Container components = null;

 

        private clsDrawThread myDrawThread = null;

        private Thread thdDraw = null;

        public frmGraphView()

        {

            //

            // Required for Windows Form Designer support

            //

            InitializeComponent();

 

            //

            // TODO: Add any constructor code after InitializeComponent call

            //

        }

 

        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 19
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 19
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值