/// <summary> /// Ulozi obrazek ve formatu GIF /// </summary> /// <param name="filename"></param> /// <param name="delay"></param> /// <param name="repeat"></param> public void SaveToGif(string path, short delay, bool repeat) { AnimatedGifEncoder aniEncoder = new AnimatedGifEncoder(); aniEncoder.Start(path); aniEncoder.SetDelay(delay); aniEncoder.SetRepeat(repeat ? 0 : -1); using (MemoryStream memoryStream = new MemoryStream()) { int lastIndex = morphManager.KeyFrames[morphManager.KeyFrames.Count - 1].Index; for (int i = 0; i <= lastIndex; i++) { Morphing.Core.Frame frame = morphManager.GetFrame(i); if (frame.WarpedBitmap == null) { continue; } // Vytvoreni gif obrazku a vlozeni do kolekce snimku GifBitmapEncoder gifEncoder = new GifBitmapEncoder(); gifEncoder.Frames.Add(BitmapFrame.Create(frame.WarpedBitmap)); gifEncoder.Save(memoryStream); aniEncoder.AddFrame(System.Drawing.Image.FromStream(memoryStream)); memoryStream.Seek(0, SeekOrigin.Begin); } aniEncoder.Finish(); } selectedFrame.ApplyWarping(); }
/// <summary> /// Inicializuje scenu do puvodni podoby /// </summary> public void Reset() { morphManager.RemoveAllFrames(); clearDrawing(); selectedFrame = morphManager.GetFrame(0); if (SelectedFrameChanged != null) { SelectedFrameChanged(this, EventArgs.Empty); } }
public Scene() { selectedFrame = morphManager.GetFrame(0); }