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();
内存递增各位老大看看,解释一下。谢谢了。
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();
内存递增各位老大看看,解释一下。谢谢了。
MyImage = new Bitmap(fileName); 定时器中每次重新装载图像
if (this.PictureBox.Image != null)
{
this.PictureBox.Image.Dispose();
this.PictureBox.Image = null;
}
this.ctrlPictureBox.Image = MyImage; 编译时,提示参数错误
什么错误?这段代码应该是可以的,用类似的代码我是可以编译成功的。
MyImage = new Bitmap(fileName);
以上部分在初始化部分赋值在定时器中实现图片的更换。
void timer_tick()
{
if (this.PictureBox.Image != null)
{
this.PictureBox.Image.Dispose();
this.PictureBox.Image = null;
}
this.ctrlPictureBox.Image = MyImage; }
程序运行时提示参数异常。
void timer_tick()
{
if (this.PictureBox.Image != null)
{
this.PictureBox.Image.Dispose();
this.PictureBox.Image = null;
}
MyImage = new Bitmap(filename);
this.ctrlPictureBox.Image = MyImage; }
你不断的把它实例化,内存肯定会增加啊