c#winform中GDI+画图,刚开始我是在panel上放了一个pictureBox,然后定义了一个Graphics对象:Bitmap bm = new Bitmap(width,height); 画了后最后pictureBox1.Image=bm;数据量少了运行速度还可以,但是当数据量很大时,比如画上一万条数据后机子就运行很慢,占的内存很大,有时达到了190M。我想所有的数据(bm对象)都保存在内存中,就是很占内存,所以我又在在panel里的paint里直接画图,但每次下拉时重画怎么那么闪啊?用什么更好的解决办法没有?再线等
SetStyle ( ControlStyles.AllPaintingInWmPaint , true ) ; // 忽略系统消息,防止图像闪烁
{
public MyPanel()
{
//
// TODO: Add constructor logic here
//
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
}
}
Dim bmpgraphics_bay_map As Graphics
bmp_bay_map = New Bitmap(800, 900) '(Me.Pl_bay_map.Width, Me.Pl_bay_map.Height)
bmpgraphics_bay_map = Graphics.FromImage(bmp_bay_map)
Me.Pl_bay_map.BackgroundImage = bmp_bay_map