To test, scaled down rendering to 25%

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

No files matched your search

@@ -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)
);
}
}
}
+10 -6
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);
}
+1 -1
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);