title: C# gif Image to MemoryStream and back (lose animation)
body: <p>I have a small problem and I do not find any solutions.
  I want to convert a GIF to a byte[] and then back to a GIF. I works fine but I lose the animation.</p>
  
  <p>It is a perfectly animated GIF when I start (I show it in a <code>PictureBox</code> element). But after conversion I get stuck with the first frame.</p>
  
  <pre><code>HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create("creativetechs.com/i/tip_images/ExampleAnimation.gif");
  HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
  Stream stream = httpWebReponse.GetResponseStream();
  Image img = Image.FromStream(stream);
  
  MemoryStream ms = new MemoryStream();
  img.Save(ms,img.RawFormat);
  byte [] bytes = ms.ToArray();
  Image img2 = Image.FromStream(new MemoryStream(bytes));
  
  int frames1 = img.GetFrameCount(System.Drawing.Imaging.FrameDimension.Time);
  int frames2 = img2.GetFrameCount(System.Drawing.Imaging.FrameDimension.Time);
  </code></pre>
  
  <p>I also tried to use not RawFormat but <code>System.Drawing.Imaging.ImageFormat.Gif</code>. Didn't change a thing. <code>frames1</code> is right number of frames. <code>frames2</code> is 1.</p>
  
  <p>I have 2 <code>PictureBox</code> elements in my GUI. One showing <code>img</code> and the other <code>img2</code>. But <code>img2</code> is not animated while <code>img</code> is. What is wrong?</p>
  
  <p>I have also tried to use serialization instead to create my byte[].</p>
  
  <p>I serialized the image and deserialized it again and it didn't change anything either. How is this possible?</p>