c#winform中GDI+画图,刚开始我是在panel上放了一个pictureBox,然后定义了一个Graphics对象:Bitmap  bm  =  new  Bitmap(width,height);  画了后最后pictureBox1.Image=bm;数据量少了运行速度还可以,但是当数据量很大时,比如画上一万条数据后机子就运行很慢,占的内存很大,有时达到了190M。我想所有的数据(bm对象)都保存在内存中,就是很占内存,所以我又在在panel里的paint里直接画图,但每次下拉时重画怎么那么闪啊?我也加了双缓冲,但下拉时还是很闪。用什么更好的解决办法没有?再线等

解决方案 »

  1.   

    不知道理解得对不对,是要在panel上画一张图吗?如果是的话应该画到一张位图上,“比如画上一万条数据后机子就运行很慢”是画在一张位图上,还是说创建很多位图对象?
      

  2.   

    是画在一张位图上. 先建一个Graphics对象:Bitmap  bm  =  new  Bitmap(width,height);然后在bm上画,所有的数据画完后在把pictureBox1.Image=bm;
      

  3.   

    using System;
    using System.Windows.Forms;
    namespace names
    {
    /// <summary>
    /// Summary description for MyPanel.
    /// </summary>
    public class MyPanel:System.Windows.Forms.Panel
    {
    public MyPanel()
    {
    //
    // TODO: Add constructor logic here
    //
    SetStyle(ControlStyles.UserPaint, true);
    SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
    SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲 }
    }
    }这样就不会闪动了。