async void SaveGIFAsync(string filename) { foreach (var frame in FFrames) { FGIF.AddFrame(frame.Image, Math.Round(FDelayTimeToCapture * 100)); //gif cannot handle arbitrary framedelays, use userinput here } try { var fileStream = new FileStream(filename, FileMode.OpenOrCreate); FGIF.Save(fileStream, (PaletteType)FPaletteType[0], (DitherType)FDitherType[0], FColorCount[0]); fileStream.Dispose(); if (FAutoOpen[0]) { Process.Start(filename); } } catch { //silently fail } finally { FFrames.Clear(); FGIF.Clear(); } }
public async void SaveGIFAsync(string filepath, PaletteType paletteType, DitherType dithertype, int colorCount = 256) { if (FCaptureState != CaptureState.Idle) { return; } FCaptureState = CaptureState.Writing; FSaveFilePath = filepath; DoReportProgress(); foreach (var frame in FFrames) { FGIF.AddFrame(frame.Image, FDelayInMilliseconds / 10); } try { var fileStream = new FileStream(filepath, FileMode.OpenOrCreate); FGIF.Save(fileStream, paletteType, dithertype, colorCount); fileStream.Dispose(); } catch { //silently fail } finally { FFrames.Clear(); FGIF.Clear(); FCaptureState = CaptureState.Idle; DoReportProgress(); } }