mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Rendering - Fixed render scale not applying until reboot
Debugger - Added button to save the next frame Device visualizer - Fixed LED positioning on some devices
This commit is contained in:
parent
456af693b0
commit
11535508bc
@ -44,6 +44,7 @@ namespace Artemis.Core.Services
|
|||||||
Surface.Exception += SurfaceOnException;
|
Surface.Exception += SurfaceOnException;
|
||||||
Surface.SurfaceLayoutChanged += SurfaceOnLayoutChanged;
|
Surface.SurfaceLayoutChanged += SurfaceOnLayoutChanged;
|
||||||
_targetFrameRateSetting.SettingChanged += TargetFrameRateSettingOnSettingChanged;
|
_targetFrameRateSetting.SettingChanged += TargetFrameRateSettingOnSettingChanged;
|
||||||
|
_renderScaleSetting.SettingChanged += RenderScaleSettingOnSettingChanged;
|
||||||
_enabledDevices = new List<ArtemisDevice>();
|
_enabledDevices = new List<ArtemisDevice>();
|
||||||
_devices = new List<ArtemisDevice>();
|
_devices = new List<ArtemisDevice>();
|
||||||
_ledMap = new Dictionary<Led, ArtemisLed>();
|
_ledMap = new Dictionary<Led, ArtemisLed>();
|
||||||
@ -196,6 +197,10 @@ namespace Artemis.Core.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RenderScaleSettingOnSettingChanged(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_texture?.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -78,7 +78,7 @@ namespace Artemis.UI.Shared
|
|||||||
penBrush.Freeze();
|
penBrush.Freeze();
|
||||||
|
|
||||||
// Create transparent pixels covering the entire LedRect so the image size matched the LedRect size
|
// Create transparent pixels covering the entire LedRect so the image size matched the LedRect size
|
||||||
drawingContext.DrawRectangle(new SolidColorBrush(Colors.Transparent), null, LedRect);
|
drawingContext.DrawRectangle(new SolidColorBrush(Colors.Transparent), new Pen(new SolidColorBrush(Colors.Transparent), 1), LedRect);
|
||||||
// Translate to the top-left of the LedRect
|
// Translate to the top-left of the LedRect
|
||||||
drawingContext.PushTransform(new TranslateTransform(LedRect.X, LedRect.Y));
|
drawingContext.PushTransform(new TranslateTransform(LedRect.X, LedRect.Y));
|
||||||
// Render the LED geometry
|
// Render the LED geometry
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Debug.Tabs"
|
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Debug.Tabs"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance local:RenderDebugViewModel}">
|
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance local:RenderDebugViewModel}">
|
||||||
<Grid>
|
<Grid>
|
||||||
@ -12,6 +13,7 @@
|
|||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock Grid.Row="0" TextWrapping="Wrap">
|
<TextBlock Grid.Row="0" TextWrapping="Wrap">
|
||||||
In this window you can view the inner workings of Artemis.
|
In this window you can view the inner workings of Artemis.
|
||||||
@ -38,5 +40,9 @@
|
|||||||
<materialDesign:Card Grid.Row="2" Margin="0,5,0,0" Background="{StaticResource Checkerboard}">
|
<materialDesign:Card Grid.Row="2" Margin="0,5,0,0" Background="{StaticResource Checkerboard}">
|
||||||
<Image Source="{Binding CurrentFrame}" />
|
<Image Source="{Binding CurrentFrame}" />
|
||||||
</materialDesign:Card>
|
</materialDesign:Card>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="3" Margin="0 5 0 0">
|
||||||
|
<Button HorizontalAlignment="Left" Command="{s:Action SaveFrame}">SAVE FRAME</Button>
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
|
using Ookii.Dialogs.Wpf;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
using SkiaSharp.Views.WPF;
|
using SkiaSharp.Views.WPF;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
@ -17,6 +19,7 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
|||||||
private ImageSource _currentFrame;
|
private ImageSource _currentFrame;
|
||||||
private int _renderWidth;
|
private int _renderWidth;
|
||||||
private int _renderHeight;
|
private int _renderHeight;
|
||||||
|
private string _frameTargetPath;
|
||||||
|
|
||||||
public RenderDebugViewModel(ICoreService coreService)
|
public RenderDebugViewModel(ICoreService coreService)
|
||||||
{
|
{
|
||||||
@ -48,6 +51,20 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
|||||||
set => SetAndNotify(ref _renderHeight, value);
|
set => SetAndNotify(ref _renderHeight, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SaveFrame()
|
||||||
|
{
|
||||||
|
VistaSaveFileDialog dialog = new VistaSaveFileDialog {Filter = "Portable network graphic (*.png)|*.png", Title = "Save render frame"};
|
||||||
|
dialog.FileName = $"Artemis frame {DateTime.Now:yyyy-dd-M--HH-mm-ss}.png";
|
||||||
|
bool? result = dialog.ShowDialog();
|
||||||
|
if (result == true)
|
||||||
|
{
|
||||||
|
if (dialog.FileName.EndsWith(".png"))
|
||||||
|
_frameTargetPath = dialog.FileName;
|
||||||
|
else
|
||||||
|
_frameTargetPath = dialog.FileName + ".png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
_coreService.FrameRendered += CoreServiceOnFrameRendered;
|
_coreService.FrameRendered += CoreServiceOnFrameRendered;
|
||||||
@ -78,6 +95,20 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
|||||||
}
|
}
|
||||||
|
|
||||||
using SKImage skImage = SKImage.FromPixels(e.Texture.Bitmap.PeekPixels());
|
using SKImage skImage = SKImage.FromPixels(e.Texture.Bitmap.PeekPixels());
|
||||||
|
|
||||||
|
if (_frameTargetPath != null)
|
||||||
|
{
|
||||||
|
using (SKData data = skImage.Encode(SKEncodedImageFormat.Png, 100))
|
||||||
|
{
|
||||||
|
using (FileStream stream = File.OpenWrite(_frameTargetPath))
|
||||||
|
{
|
||||||
|
data.SaveTo(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_frameTargetPath = null;
|
||||||
|
}
|
||||||
|
|
||||||
SKImageInfo info = new(skImage.Width, skImage.Height);
|
SKImageInfo info = new(skImage.Width, skImage.Height);
|
||||||
writable.Lock();
|
writable.Lock();
|
||||||
using (SKPixmap pixmap = new(info, writable.BackBuffer, writable.BackBufferStride))
|
using (SKPixmap pixmap = new(info, writable.BackBuffer, writable.BackBufferStride))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user