1
我在硬盘上检查了GIF动画创建,我打开它在Internet Explorer中,它的工作。为什么即时图片框中的白色背景变成大红色X而不是动画GIF?
所以我不明白为什么我得到这个白色大x红。
我用断点,并没有得到任何错误到目前为止。
真正建立在这个类gif动画的是,这个行号175:
unfreez.MakeGIF(myGifList, previewFileName, 8, true);
而且gif动画是真的存在,created.In线210即时调用一个加载gif动画的功能在PictureBox:
pictureBoxImage(previewFileName);
这是pictureBoxImage函数,其中我用的断点,并没有显示任何错误:
public void pictureBoxImage(string pbImage)
{
Image img2 = null;
try
{
using (img = Image.FromFile(pbImage))
{
//get the old image thats loaded from the _memSt memorystream
//and dispose it
Image i = this.pictureBox1.Image;
this.pictureBox1.Image = null;
if (i != null)
i.Dispose();
//grab the old stream
MemoryStream m = _memSt;
//save the new image to this stream
_memSt = new MemoryStream();
img.Save(_memSt, System.Drawing.Imaging.ImageFormat.Gif);
if (m != null)
m.Dispose();
//create our image to display
img2 = Image.FromStream(_memSt);
}
if (img2 != null)
pictureBox1.Image = img2;
//label2.Text = numberOfFiles.ToString();
//label6.Text = nameOfStartFile.ToString();
//label4.Text = nameOfEndFile.ToString();
//File.Delete(pbImage);
}
catch (Exception err)
{
Logger.Write("Animation Error >>> " + err);
}
}
不知道为什么?红色的x和白色背景。
我没有复制到这里全班,但我会如果它的需要,但动画gif创建良好和工作在互联网浏览器,所以班正在工作,但在pictureBox dosent工作出于某种原因。
红色的x和白色背景表示文件未找到...或者内存流无法转换回gif。 – NoviceProgrammer
红十字是广义的“渲染失败”表示,我经常看到它与DirectX一起工作。至于具体的原因... – Jodrell
问题是在类顶部我做到了:pictureBox1.Image.Dispose();当我标记它/ /所以它的工作。但有时候,我点击按钮来使动画GIF它没有工作,它显示了我在设计器中添加的默认pictureBox1图像。所以出于某种原因,我不知何故我需要发布来处置pictureBox每次im调用类。所以从一方面来说,我认为我需要使它成为问题的另一方面。 – user1477444