Create Bitmap from Collection of BitmapSources
<p>I would like to create the Bitmap from BitmapSource Collection  and Each source source should be one frame.</p>

<p>I wrote the following code</p>

<pre><code>MemoryStream memStream = new MemoryStream();
BitmapEncoder enCoder = new GifBitmapEncoder();

foreach (BitmapSource source in BitmapSources)
    enCoder.Frames.Add(BitmapFrame.Create(source));
enCoder.Save(memStream);
_Bitmap = new DrawingCtrl.Bitmap(memStream);

DrawingCtrl.ImageAnimator.Animate(_Bitmap, OnFrameChanged);
</code></pre>

<p>and</p>

<pre><code>private void OnFrameChangedInMainThread()
{
    DrawingCtrl.ImageAnimator.UpdateFrames(_Bitmap);
    Source = GetBitmapSource(_Bitmap);
    InvalidateVisual();
}
</code></pre>

<p>But it shows <code>"Exception has been thrown by the target of an invocation."</code>. Could anyone help me?</p>
