Merge pull request #517 from Artemis-RGB/feature/color-calibration

Added Per device color calibration
This commit is contained in:
Robert Beekman authored and GitHub committed 2020-12-12 21:11:41 +01:00
commit 36058efc4d
8 files changed
+343 -46

No files matched your search

@@ -27,6 +27,9 @@ namespace Artemis.Core
Rotation = 0;
Scale = 1;
ZIndex = 1;
RedScale = 1;
GreenScale = 1;
BlueScale = 1;
deviceProvider.DeviceLayoutPaths.TryGetValue(rgbDevice, out string? layoutPath);
LayoutPath = layoutPath;
@@ -171,6 +174,45 @@ namespace Artemis.Core
}
}
/// <summary>
/// Gets or sets the scale of the red color component used for calibration
/// </summary>
public double RedScale
{
get => DeviceEntity.RedScale;
set
{
DeviceEntity.RedScale = value;
OnPropertyChanged(nameof(RedScale));
}
}
/// <summary>
/// Gets or sets the scale of the green color component used for calibration
/// </summary>
public double GreenScale
{
get => DeviceEntity.GreenScale;
set
{
DeviceEntity.GreenScale = value;
OnPropertyChanged(nameof(GreenScale));
}
}
/// <summary>
/// Gets or sets the scale of the blue color component used for calibration
/// </summary>
public double BlueScale
{
get => DeviceEntity.BlueScale;
set
{
DeviceEntity.BlueScale = value;
OnPropertyChanged(nameof(BlueScale));
}
}
/// <summary>
/// Gets the path to where the layout of the device was (attempted to be) loaded from
/// </summary>
@@ -57,5 +57,14 @@ namespace Artemis.Core
{
return RgbLed.ToString();
}
/// <summary>
/// Gets the color of this led, reverting the correction done to the parent device
/// </summary>
/// <returns></returns>
public Color GetOriginalColor()
{
return RgbLed.Color.DivideRGB(Device.RedScale, Device.GreenScale, Device.BlueScale);
}
}
}
+14 -3
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using RGB.NET.Core;
using SkiaSharp;
@@ -101,7 +101,13 @@ namespace Artemis.Core
{
Point scaledLocation = renderTarget.Point * Scale;
if (scaledLocation.X < Bitmap.Width && scaledLocation.Y < Bitmap.Height)
RenderedTargets[renderTarget] = Bitmap.GetPixel(scaledLocation.X.RoundToInt(), scaledLocation.Y.RoundToInt()).ToRgbColor();
{
var pixel = Bitmap.GetPixel(scaledLocation.X.RoundToInt(), scaledLocation.Y.RoundToInt()).ToRgbColor();
var artemisDevice = Surface?.GetArtemisLed(renderTarget.Led)?.Device;
if (artemisDevice is not null)
pixel = pixel.MultiplyRGB(artemisDevice.RedScale, artemisDevice.GreenScale, artemisDevice.BlueScale);
RenderedTargets[renderTarget] = pixel;
}
}
}
@@ -148,8 +154,13 @@ namespace Artemis.Core
// Bitmap.SetPixel(x, y, new SKColor(0, 255, 0));
}
}
var pixel = new Color(a / sampleSize, r / sampleSize, g / sampleSize, b / sampleSize);
RenderedTargets[renderTarget] = new Color(a / sampleSize, r / sampleSize, g / sampleSize, b / sampleSize);
var artemisDevice = Surface?.GetArtemisLed(renderTarget.Led)?.Device;
if (artemisDevice is not null)
pixel = pixel.MultiplyRGB(artemisDevice.RedScale, artemisDevice.GreenScale, artemisDevice.BlueScale);
RenderedTargets[renderTarget] = pixel;
}
}