ScreenToGif.Windows.Board.AddFrames C# (CSharp) Method

AddFrames() private method

Saves the Bitmap to the disk.
private AddFrames ( string fileName, System.Windows.Media.Imaging.BitmapSource bitmap ) : void
fileName string The final filename of the Bitmap.
bitmap System.Windows.Media.Imaging.BitmapSource The Bitmap to save in the disk.
return void
        private void AddFrames(string fileName, BitmapSource bitmap)
        {
            //var mutexLock = new Mutex(false, bitmap.GetHashCode().ToString());
            //mutexLock.WaitOne();

            using (var stream = new FileStream(fileName, FileMode.Create))
            {
                BmpBitmapEncoder encoder = new BmpBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(bitmap));
                encoder.Save(stream);
                stream.Flush();
                stream.Close();
            }

            //GC.Collect(1);
            //mutexLock.ReleaseMutex();
        }