1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Surface resize fixes

This commit is contained in:
Robert 2019-12-04 19:58:55 +01:00
parent 8ba2e58c5d
commit 49cf96e12c
2 changed files with 12 additions and 2 deletions

View File

@ -220,7 +220,10 @@ namespace Artemis.Core.Services.Storage
private void RenderScaleSettingOnSettingChanged(object sender, EventArgs e) private void RenderScaleSettingOnSettingChanged(object sender, EventArgs e)
{ {
foreach (var surfaceConfiguration in SurfaceConfigurations) foreach (var surfaceConfiguration in SurfaceConfigurations)
{
surfaceConfiguration.UpdateScale(_renderScaleSetting.Value); surfaceConfiguration.UpdateScale(_renderScaleSetting.Value);
OnSurfaceConfigurationUpdated(new SurfaceConfigurationEventArgs(surfaceConfiguration));
}
} }
#endregion #endregion

View File

@ -4,6 +4,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using Artemis.Core.Events; using Artemis.Core.Events;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage.Interfaces;
using SkiaSharp; using SkiaSharp;
using SkiaSharp.Views.WPF; using SkiaSharp.Views.WPF;
using Stylet; using Stylet;
@ -15,10 +16,13 @@ namespace Artemis.UI.Screens.Settings.Debug
private readonly ICoreService _coreService; private readonly ICoreService _coreService;
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public DebugViewModel(ICoreService coreService, IRgbService rgbService) public DebugViewModel(ICoreService coreService, IRgbService rgbService, ISurfaceService surfaceService)
{ {
_coreService = coreService; _coreService = coreService;
_rgbService = rgbService; _rgbService = rgbService;
surfaceService.SurfaceConfigurationUpdated += (sender, args) => Execute.PostToUIThread(() => CurrentFrame = null);
surfaceService.ActiveSurfaceConfigurationChanged += (sender, args) => Execute.PostToUIThread(() => CurrentFrame = null);
} }
public ImageSource CurrentFrame { get; set; } public ImageSource CurrentFrame { get; set; }
@ -36,6 +40,9 @@ namespace Artemis.UI.Screens.Settings.Debug
{ {
Execute.PostToUIThread(() => Execute.PostToUIThread(() =>
{ {
if (e.GraphicsDecorator.Bitmap == null)
return;
if (!(CurrentFrame is WriteableBitmap writeableBitmap)) if (!(CurrentFrame is WriteableBitmap writeableBitmap))
{ {
CurrentFrame = e.GraphicsDecorator.Bitmap.ToWriteableBitmap(); CurrentFrame = e.GraphicsDecorator.Bitmap.ToWriteableBitmap();
@ -51,7 +58,7 @@ namespace Artemis.UI.Screens.Settings.Debug
skiaImage.ReadPixels(pixmap, 0, 0); skiaImage.ReadPixels(pixmap, 0, 0);
} }
writeableBitmap.AddDirtyRect(new Int32Rect(0, 0, info.Width, info.Height)); writeableBitmap.AddDirtyRect(new Int32Rect(0, 0, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight));
writeableBitmap.Unlock(); writeableBitmap.Unlock();
} }
}); });