public void PushFrame(EffectFrame frame) { var watch = System.Diagnostics.Stopwatch.StartNew(); lock (bitmap_lock) { EffectLayer background = new EffectLayer("Global Background", Color.FromArgb(0, 0, 0)); EffectLayer[] over_layers_array = frame.GetOverlayLayers().ToArray(); EffectLayer[] layers_array = frame.GetLayers().ToArray(); foreach (EffectLayer layer in layers_array) { background += layer; } foreach (EffectLayer layer in over_layers_array) { background += layer; } //Apply Brightness Color peri_col = background.Get(DeviceKeys.Peripheral); background.Set(DeviceKeys.Peripheral, Utils.ColorUtils.BlendColors(peri_col, Color.Black, (1.0f - Global.Configuration.peripheral_brightness_modifier))); background.Fill(Color.FromArgb((int)(255.0f * (1.0f - Global.Configuration.keyboard_brightness_modifier)), Color.Black)); if (Global.Configuration.use_volume_as_brightness) { background *= Global.Configuration.global_brightness; } Dictionary <DeviceKeys, Color> keyColors = new Dictionary <DeviceKeys, Color>(); Devices.DeviceKeys[] allKeys = bitmap_map.Keys.ToArray(); foreach (Devices.DeviceKeys key in allKeys) { keyColors[key] = background.Get(key); } Effects.keyColors = new Dictionary <DeviceKeys, Color>(keyColors); pushedframes++; Global.dev_manager.UpdateDevices(keyColors); var hander = NewLayerRender; if (hander != null) { hander.Invoke(background.GetBitmap()); } if (isrecording) { EffectLayer pizelated_render = new EffectLayer(); foreach (Devices.DeviceKeys key in allKeys) { pizelated_render.Set(key, background.Get(key)); } using (Bitmap map = pizelated_render.GetBitmap()) { previousframe = new Bitmap(map); } } frame.Dispose(); } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; }