我检查了硬盘上创建的动画gif,我在Internet Explorer中打开它并且它有效。
所以我不明白为什么我用大x红色得到这个白色。
我使用断点并且到目前为止没有任何错误。
此类中动画gif的真正创建是第175行:
unfreez.MakeGIF(myGifList, previewFileName, 8, true);
动画gif真的存在并且已经创建。在第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创建得很好并且在Internet Explorer上工作所以班级正在工作但是在pictureBox上的显示因为某些原因而起作用。
答案 0 :(得分:2)
肖恩·哈格里夫斯(Shawn Hargreaves)有一个非常简洁的writeup大红色X"。我发现在处理WinForm组件的一般情况下突然显示红色" X"非常有帮助。
总结:
OnPaint
事件中抛出异常引起的。OnPaint.