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:
parent
93cd704c6c
commit
5cdde6e402
@ -4,9 +4,14 @@ namespace Artemis.Core.Extensions
|
|||||||
{
|
{
|
||||||
public static class RgbRectangleExtensions
|
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)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9,17 +9,20 @@ namespace Artemis.Core.RGB.NET
|
|||||||
{
|
{
|
||||||
public class GraphicsDecorator : AbstractDecorator, IBrushDecorator, IDisposable
|
public class GraphicsDecorator : AbstractDecorator, IBrushDecorator, IDisposable
|
||||||
{
|
{
|
||||||
|
private readonly double _scale;
|
||||||
private DirectBitmap _bitmap;
|
private DirectBitmap _bitmap;
|
||||||
|
|
||||||
public GraphicsDecorator(ILedGroup ledGroup)
|
public GraphicsDecorator(ILedGroup ledGroup, double scale)
|
||||||
{
|
{
|
||||||
|
_scale = scale;
|
||||||
|
|
||||||
var leds = ledGroup.GetLeds().ToList();
|
var leds = ledGroup.GetLeds().ToList();
|
||||||
if (!leds.Any())
|
if (!leds.Any())
|
||||||
_bitmap = null;
|
_bitmap = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var width = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.X + l.AbsoluteLedRectangle.Width), 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), 2000);
|
var height = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.Y + l.AbsoluteLedRectangle.Height) * scale, 4096);
|
||||||
|
|
||||||
_bitmap = new DirectBitmap((int) width, (int) height);
|
_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)
|
public Color ManipulateColor(Rectangle rectangle, BrushRenderTarget renderTarget, Color color)
|
||||||
{
|
{
|
||||||
var point = renderTarget.Led.AbsoluteLedRectangle.Center;
|
var x = renderTarget.Led.AbsoluteLedRectangle.Center.X * _scale;
|
||||||
if (_bitmap != null && _bitmap.Width - 1 >= point.X && _bitmap.Height - 1 >= point.Y)
|
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);
|
return new Color(pixel.A, pixel.R, pixel.G, pixel.B);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -108,7 +108,7 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
// Apply the application wide brush and decorator
|
// Apply the application wide brush and decorator
|
||||||
_background = new ListLedGroup(Surface.Leds) {Brush = new SolidColorBrush(new Color(255, 255, 255, 255))};
|
_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.RemoveAllDecorators();
|
||||||
|
|
||||||
_background.Brush.AddDecorator(GraphicsDecorator);
|
_background.Brush.AddDecorator(GraphicsDecorator);
|
||||||
|
|||||||
@ -87,7 +87,7 @@ namespace Artemis.Plugins.Modules.General
|
|||||||
Colors[index] = color;
|
Colors[index] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rectangle = led.AbsoluteLedRectangle.ToDrawingRectangle();
|
var rectangle = led.AbsoluteLedRectangle.ToDrawingRectangle(0.25);
|
||||||
graphics.FillRectangle(new SolidBrush(color), rectangle);
|
graphics.FillRectangle(new SolidBrush(color), rectangle);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,10 @@ namespace Artemis.UI.ViewModels.Screens
|
|||||||
var imageSource = ImageSourceFromBitmap(e.Bitmap);
|
var imageSource = ImageSourceFromBitmap(e.Bitmap);
|
||||||
imageSource.Freeze();
|
imageSource.Freeze();
|
||||||
CurrentFps = Math.Round(1.0 / e.DeltaTime, 2);
|
CurrentFps = Math.Round(1.0 / e.DeltaTime, 2);
|
||||||
Execute.OnUIThread(() => CurrentFrame = imageSource);
|
Execute.OnUIThread(() =>
|
||||||
|
{
|
||||||
|
CurrentFrame = imageSource;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClose()
|
protected override void OnClose()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user