From f04d7cf8972406eefe29ad2088d04fd8e8d1c1a1 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 11 May 2023 23:33:36 +0200 Subject: [PATCH] BitmapInterpolationMode fixes --- .../Controls/DeviceVisualizer.cs | 4 +- .../Controls/DeviceVisualizerLed.cs | 6 +-- .../Screens/Device/DeviceSettingsView.axaml | 37 ++++++++++--------- src/Artemis.UI/Screens/Root/SplashView.axaml | 2 +- .../SurfaceEditor/SurfaceDeviceView.axaml | 2 +- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index 8541d98a6..3d8a3192e 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -41,7 +41,6 @@ public class DeviceVisualizer : Control PropertyChanged += OnPropertyChanged; } - /// public override void Render(DrawingContext drawingContext) { @@ -305,8 +304,9 @@ public class DeviceVisualizer : Control using DrawingContext context = renderTargetBitmap.CreateDrawingContext(); using Bitmap bitmap = new(device.Layout.Image.LocalPath); + using Bitmap scaledBitmap = bitmap.CreateScaledBitmap(renderTargetBitmap.PixelSize); - context.DrawImage(bitmap, new Rect(bitmap.Size), new Rect(renderTargetBitmap.Size)); + context.DrawImage(scaledBitmap, new Rect(scaledBitmap.Size)); lock (_deviceVisualizerLeds) { foreach (DeviceVisualizerLed deviceVisualizerLed in _deviceVisualizerLeds) diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs index 29e219fb9..6c69cc674 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs @@ -46,10 +46,10 @@ internal class DeviceVisualizerLed try { using Bitmap bitmap = new(Led.Layout.Image.LocalPath); + using Bitmap scaledBitmap = bitmap.CreateScaledBitmap(new PixelSize((Led.RgbLed.Size.Width * scale).RoundToInt(), (Led.RgbLed.Size.Height * scale).RoundToInt())); drawingContext.DrawImage( - bitmap, - new Rect(bitmap.Size), - new Rect(Led.RgbLed.Location.X * scale, Led.RgbLed.Location.Y * scale, Led.RgbLed.Size.Width * scale, Led.RgbLed.Size.Height * scale) + scaledBitmap, + new Rect(Led.RgbLed.Location.X * scale, Led.RgbLed.Location.Y * scale, scaledBitmap.Size.Width, scaledBitmap.Size.Height) ); } catch diff --git a/src/Artemis.UI/Screens/Device/DeviceSettingsView.axaml b/src/Artemis.UI/Screens/Device/DeviceSettingsView.axaml index 6c6330055..080b36def 100644 --- a/src/Artemis.UI/Screens/Device/DeviceSettingsView.axaml +++ b/src/Artemis.UI/Screens/Device/DeviceSettingsView.axaml @@ -11,13 +11,14 @@ x:Class="Artemis.UI.Screens.Device.DeviceSettingsView"> - - + + RenderOptions.BitmapInterpolationMode="HighQuality" />