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

To test, scaled down rendering to 25%

This commit is contained in:
Robert 2019-10-25 17:30:07 +02:00
parent 93cd704c6c
commit 5cdde6e402
5 changed files with 23 additions and 11 deletions

View File

@ -4,9 +4,14 @@ namespace Artemis.Core.Extensions
{
public static class RgbRectangleExtensions
{
public static Rectangle ToDrawingRectangle(this global::RGB.NET.Core.Rectangle rectangle)
public static Rectangle ToDrawingRectangle(this global::RGB.NET.Core.Rectangle rectangle, double scale)
{
return new Rectangle((int) rectangle.X, (int) rectangle.Y, (int) rectangle.Width, (int) rectangle.Height);
return new Rectangle(
(int) (rectangle.X * scale),
(int) (rectangle.Y * scale),
(int) (rectangle.Width * scale),
(int) (rectangle.Height * scale)
);
}
}
}

View File

@ -9,17 +9,20 @@ namespace Artemis.Core.RGB.NET
{
public class GraphicsDecorator : AbstractDecorator, IBrushDecorator, IDisposable
{
private readonly double _scale;
private DirectBitmap _bitmap;
public GraphicsDecorator(ILedGroup ledGroup)
public GraphicsDecorator(ILedGroup ledGroup, double scale)
{
_scale = scale;
var leds = ledGroup.GetLeds().ToList();
if (!leds.Any())
_bitmap = null;
else
{
var width = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.X + l.AbsoluteLedRectangle.Width), 2000);
var height = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.Y + l.AbsoluteLedRectangle.Height), 2000);
var width = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.X + l.AbsoluteLedRectangle.Width) * scale, 4096);
var height = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.Y + l.AbsoluteLedRectangle.Height) * scale, 4096);
_bitmap = new DirectBitmap((int) width, (int) height);
}
@ -27,10 +30,11 @@ namespace Artemis.Core.RGB.NET
public Color ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, Color color)
{
var point = renderTarget.Led.AbsoluteLedRectangle.Center;
if (_bitmap != null && _bitmap.Width - 1 >= point.X && _bitmap.Height - 1 >= point.Y)
var x = renderTarget.Led.AbsoluteLedRectangle.Center.X * _scale;
var y = renderTarget.Led.AbsoluteLedRectangle.Center.Y * _scale;
if (_bitmap != null && _bitmap.Width - 1 >= x && _bitmap.Height - 1 >= y)
{
var pixel = _bitmap.GetPixel((int) point.X, (int) point.Y);
var pixel = _bitmap.GetPixel((int) x, (int) y);
return new Color(pixel.A, pixel.R, pixel.G, pixel.B);
}

View File

@ -108,7 +108,7 @@ namespace Artemis.Core.Services
// Apply the application wide brush and decorator
_background = new ListLedGroup(Surface.Leds) {Brush = new SolidColorBrush(new Color(255, 255, 255, 255))};
GraphicsDecorator = new GraphicsDecorator(_background);
GraphicsDecorator = new GraphicsDecorator(_background, 0.25);
_background.Brush.RemoveAllDecorators();
_background.Brush.AddDecorator(GraphicsDecorator);

View File

@ -87,7 +87,7 @@ namespace Artemis.Plugins.Modules.General
Colors[index] = color;
}
var rectangle = led.AbsoluteLedRectangle.ToDrawingRectangle();
var rectangle = led.AbsoluteLedRectangle.ToDrawingRectangle(0.25);
graphics.FillRectangle(new SolidBrush(color), rectangle);
index++;
}

View File

@ -38,7 +38,10 @@ namespace Artemis.UI.ViewModels.Screens
var imageSource = ImageSourceFromBitmap(e.Bitmap);
imageSource.Freeze();
CurrentFps = Math.Round(1.0 / e.DeltaTime, 2);
Execute.OnUIThread(() => CurrentFrame = imageSource);
Execute.OnUIThread(() =>
{
CurrentFrame = imageSource;
});
}
protected override void OnClose()