【发布时间】:2012-07-03 03:12:57
【问题描述】:
我在硬盘上检查了动画 gif 的创建,我在 Internet Explorer 中打开它,它工作正常。
所以我不明白为什么我把这个白色配上大 x 红色。
我使用了断点,目前没有出现任何错误。
这个类中真正创建的gif动画是这行号175:
unfreez.MakeGIF(myGifList, previewFileName, 8, true);
动画 gif 是真实存在和创建的。在第 210 行中,我调用了将动画 gif 加载到图片框的函数:
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 上的显示无法正常工作。
【问题讨论】:
-
红x白底表示文件未找到……或者内存流无法转回gif。
-
红叉是广义的“渲染失败”表示,我经常看到它与 DirectX 一起使用。至于具体原因……
-
问题出在我做的顶级课程中:pictureBox1.Image.Dispose();当我将它标记为 // 所以它的工作。但是过了一段时间,我点击了按钮来制作动画 gif,它没有显示我在设计器中添加的默认图片框 1 图像。因此,出于某种原因,我每次调用类时都需要释放以处理图片框。因此,一方面我认为我需要在另一方面解决问题。
标签: c#