picturebox控件资源释放问题?
MyImage 定义为外部变量
MyImage = new Bitmap(fileName);
定时器中每次重新装载图像
if (this.PictureBox.Image != null)
{
this.PictureBox.Image.Dispose();
this.PictureBox.Image = null;
}
this.ctrlPictureBox.Image = MyImage;
编译时,提示参数错误
修改为
if (this.PictureBox.Image != null)
{
this.PictureBox.Image.Dispose();
this.PictureBox.Image = null;
}
this.PictureBox.Image = (Image)MyImage.Clone();
图像显示时闪烁
修改为
if (this.PictureBox.Image != null)
{
this.PictureBox.Image.Dispose();
}
this.PictureBox.Image = (Image)MyImage.Clone();
内存递增
各位老大看看,解释一下。谢谢了。