1

I checked on the hard disk the animated gif is created and i opened it in internet explorer and it worked.

So i dont understand why im getting this white with big x red.

I used breakpoint and didnt get any errors so far.

The real creation of the animated gif in this class is this line number 175:

unfreez.MakeGIF(myGifList, previewFileName, 8, true);

And the animated gif is realy exist and created.In line 210 im calling the function that load the animated gif to the pictureBox:

pictureBoxImage(previewFileName);

And this is the pictureBoxImage function where i used breakpoint and it didnt show any errors:

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);
    }
}

Cant figure out why ? The red x and white background.

I didnt copy to here the whole class but i will if its needed but the animated gif is created good and working on internet explorer so the class is working but the showing on the pictureBox dosent work for some reason.

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
user1477444
  • 107
  • 1
  • 2
  • 12
  • 1
    The red x and white background means that the file was not found...or that the memory stream could not be converted back to gif. – NoviceProgrammer Jul 02 '12 at 17:30
  • The red cross is the generalised "failure to render" representation, I've seen it often working with DirectX. As to the specific cause ... – Jodrell Jul 02 '12 at 17:33
  • The problem was in the class top i did: pictureBox1.Image.Dispose(); When i mark it to // so its working. But after some times i clicked the button to make the animated gif it didnt work its showing the default pictureBox1 image i added in the designer. So for some reason and somehow i need to release to dispose the pictureBox each time im calling the class . So from one hand i think i need to make it in the other hand its making the problem. – user1477444 Jul 02 '12 at 17:39

1 Answers1

3

Shawn Hargreaves has an excellent, concise writeup of the "big red X of doom". I found it very helpful in the general case of dealing with WinForm components suddenly showing the red "X".

In summary:

  • This is caused by a control throwing an exception out of the OnPaint event.
  • Once it is thrown, that control will continue to show the red X and skip firing OnPaint.
  • To debug, set the debugger to catch Common Language Runtime Exceptions, and then do whatever you normally do to get the red X. The debugger will stop right where it is happening, allowing you to investigate and hopefully figure out a way to prevent it.
Mark Meuer
  • 7,200
  • 6
  • 43
  • 64