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