private static async Task RunCacheSavingQueueAsync() { await Task.Delay(TimeSpan.FromSeconds(5d)); while (_cache.Count > 0) { Tuple <string, ReplayDetails> itemToSave = null; lock (_cacheToSave) { var count = _cacheToSave.Count; if (count > 0) { itemToSave = _cacheToSave[count - 1]; _cacheToSave.RemoveAt(count - 1); } } if (itemToSave != null) { using (var output = File.Create(itemToSave.Item1)) using (var gzip = new DeflateStream(output, CompressionMode.Compress)) { gzip.WriteBytes(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(itemToSave.Item2))); } await Task.Delay(TimeSpan.FromSeconds(1d)); } else { await Task.Delay(TimeSpan.FromSeconds(10d)); } } }
public override void Save(FrameInfo info) { if (UserSettings.All.PreventBlackFrames && info.Data != null && !info.FrameSkipped && info.Data[0] == 0) { if (!info.Data.Any(a => a > 0)) { info.FrameSkipped = true; } } //If the frame skipped, just increase the delay to the previous frame. if (info.FrameSkipped || info.Data == null) { info.Data = null; //Pass the duration to the previous frame, if any. if (Project.Frames.Count > 0) { Project.Frames[Project.Frames.Count - 1].Delay += info.Delay; } return; } _compressStream.WriteBytes(info.Data); info.Data = null; Project.Frames.Add(info); }
public override void Save(FrameInfo info) { _compressStream.WriteBytes(info.Data); info.Data = null; Project.Frames.Add(info); }
public static void CompressToFile(this byte[] data, FileInfo destFile) { using (var fileStream = destFile.Create()) using (var compressionStream = new DeflateStream(fileStream, CompressionMode.Compress)) { compressionStream.WriteBytes(data); } }
public override void Save(FrameInfo info) { System.Diagnostics.Debug.WriteLine("Length:" + info.Data.Length + " " + _fileStream.Length); _compressStream.WriteBytes(info.Data); _compressStream.Flush(); info.Data = null; Project.Frames.Add(info); }
public override void Save(FrameInfo info) { //Due to a strange behavior with the GetDiBits method while the cursor is IBeam, i have to set back all alpha bits to 255. //if (info.RemoveAnyTransparency) // for (var i = 3; i < _byteLength; i += 4) // info.Data[i] = 255; _compressStream.WriteBytes(info.Data); info.Data = null; Project.Frames.Add(info); }
public override void Save(FrameInfo info) { //If the frame skipped, just increase the delay to the previous frame. if (info.FrameSkipped) { info.Data = null; Project.Frames[Project.Frames.Count - 1].Delay += info.Delay; return; } _compressStream.WriteBytes(info.Data); info.Data = null; Project.Frames.Add(info); }