From c801656b0095dbb24882b6596311e08869aceac7 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Sun, 31 Jan 2016 15:25:08 +0100 Subject: [PATCH] Fixed debug display (resolves #4) and fixed volume display scaling --- .../Effects/Debug/DebugEffectViewModel.cs | 40 +++++++------------ .../Overlays/VolumeDisplay/VolumeDisplay.cs | 2 +- .../Utilities/Keyboard/KeyboardRectangle.cs | 1 + 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/Artemis/Artemis/Modules/Effects/Debug/DebugEffectViewModel.cs b/Artemis/Artemis/Modules/Effects/Debug/DebugEffectViewModel.cs index 0ad0a710f..fbf0aef89 100644 --- a/Artemis/Artemis/Modules/Effects/Debug/DebugEffectViewModel.cs +++ b/Artemis/Artemis/Modules/Effects/Debug/DebugEffectViewModel.cs @@ -1,5 +1,7 @@ using System; using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.IO; using System.Windows; using System.Windows.Interop; using System.Windows.Media; @@ -82,33 +84,19 @@ namespace Artemis.Modules.Effects.Debug public void Handle(ChangeBitmap message) { - //// Doesn't show transparancy - //using (var memory = new MemoryStream()) - //{ - // message.Bitmap.Save(memory, ImageFormat.Bmp); - // memory.Position = 0; - - // var bitmapImage = new BitmapImage(); - // bitmapImage.BeginInit(); - // bitmapImage.StreamSource = memory; - // bitmapImage.CacheOption = BitmapCacheOption.OnLoad; - // bitmapImage.EndInit(); - - // ImageSource = bitmapImage; - //} - - // Causes "Generic GDI+ Exception" after a while - try + // Doesn't show transparancy + using (var memory = new MemoryStream()) { - ImageSource = Imaging.CreateBitmapSourceFromHBitmap( - message.Bitmap.GetHbitmap(), - IntPtr.Zero, - Int32Rect.Empty, - BitmapSizeOptions.FromEmptyOptions()); - } - catch (Exception) - { - // ignored + message.Bitmap.Save(memory, ImageFormat.Png); + memory.Position = 0; + + var bitmapImage = new BitmapImage(); + bitmapImage.BeginInit(); + bitmapImage.StreamSource = memory; + bitmapImage.CacheOption = BitmapCacheOption.OnLoad; + bitmapImage.EndInit(); + + ImageSource = bitmapImage; } } diff --git a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs index 59dc55d66..63ec78619 100644 --- a/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs +++ b/Artemis/Artemis/Modules/Overlays/VolumeDisplay/VolumeDisplay.cs @@ -37,7 +37,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay }, LinearGradientMode.Horizontal) { - Width = (int) (100.00/(MainModel.ActiveKeyboard.Width*4)*Volume), + Width = (int) ((MainModel.ActiveKeyboard.Width/100.00)*Volume)*Scale, ContainedBrush = false }; volumeRect.Draw(g); diff --git a/Artemis/Artemis/Utilities/Keyboard/KeyboardRectangle.cs b/Artemis/Artemis/Utilities/Keyboard/KeyboardRectangle.cs index e0f320a6e..5f09a0b3a 100644 --- a/Artemis/Artemis/Utilities/Keyboard/KeyboardRectangle.cs +++ b/Artemis/Artemis/Utilities/Keyboard/KeyboardRectangle.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing;