title: Creating an animated Bitmap image programmatically
body: <p>I want to create a <code>System.Drawing.Bitmap</code> instance "manually", which contains an animation.</p>
  
  <p>The <code>Bitmap</code> instance to create should meet the following criteria:</p>
  
  <ul>
  <li>It is an animation (<code>image.FrameDimensionsLists</code> has a Time dimension)</li>
  <li>It has multiple frames (<code>image.GetFrameCount(dimension) &gt; 1</code>)</li>
  <li>I can obtain the delay between the frames (<code>image.GetPropertyItem(0x5100).Value</code>)</li>
  </ul>
  
  <p>I'm pretty sure it is possible to create such an image via some WinApi. This is what the GIF Decoder actually does as well.</p>
  
  <p>I know that I can play the animation if I have the frames from any source by doing it manually, but I want to do it in a compatible way: If I could produce such a Bitmap, I could simply use it on a <code>Button</code>, <code>Label</code>, <code>PictureBox</code> or any other existing control, and the built-in <code>ImageAnimator</code> could also handle it automatically.</p>
  
  <p>Most of the similar topics suggest to convert the frames into an animated GIF; however, this is not a good solution, because it does not handle true color and semi-transparency (eg. APNG animation).</p>
  
  <p><strong>Update:</strong> After some exploring I learned that I could implement a decoder using <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ee690086%28v=vs.85%29.aspx" rel="noreferrer">WIC</a>; however, I do not want to register a new decoder in Windows, and it uses COM, which I want to avoid if possible. Not mentioning that at the end I will have an <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ee690171%28v=vs.85%29.aspx" rel="noreferrer">IWICBitmapSource</a>, which I still need to convert to a <code>Bitmap</code>.</p>
  
  <p><strong>Update 2</strong>: I have set a bounty. You are the winner if you can implement the following method:</p>
  
  <pre><code>public void Bitmap CreateAnimation(Bitmap[] frames, int[] delays)
  {
      // Any WinApi is allowed. WIC is also allowed, but not preferred.
      // Creating an animated GIF is not an acceptable answer. What if frames are from an APNG?
  }
  </code></pre>