mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added color-blending to ambilight
This commit is contained in:
parent
a46e2096a7
commit
e91b06a28a
@ -413,6 +413,7 @@
|
|||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\Model\Extensions\AvgColorExtension.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\Model\Extensions\AvgColorExtension.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\Model\Extensions\PixelDataExtension.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\Model\Extensions\PixelDataExtension.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\Model\FlipMode.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\Model\FlipMode.cs" />
|
||||||
|
<Compile Include="Profiles\Layers\Types\AmbientLight\Model\SmoothMode.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\DX9ScreenCapture.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\DX9ScreenCapture.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\IScreenCapture.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\IScreenCapture.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\ScreenCaptureManager.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\ScreenCaptureManager.cs" />
|
||||||
|
|||||||
@ -32,7 +32,7 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.AmbienceCreator
|
|||||||
int effectiveSourceWidth = sourceWidth - offsetLeft - offsetRight;
|
int effectiveSourceWidth = sourceWidth - offsetLeft - offsetRight;
|
||||||
int effectiveSourceHeight = sourceHeight - offsetTop - offsetBottom;
|
int effectiveSourceHeight = sourceHeight - offsetTop - offsetBottom;
|
||||||
|
|
||||||
int relevantSourceHeight = (int)Math.Round(effectiveSourceHeight * settings.MirroredAmount);
|
int relevantSourceHeight = (int)Math.Round(effectiveSourceHeight * (settings.MirroredAmount / 100.0));
|
||||||
int relevantOffsetTop = sourceHeight - offsetBottom - relevantSourceHeight;
|
int relevantOffsetTop = sourceHeight - offsetBottom - relevantSourceHeight;
|
||||||
|
|
||||||
double widthPixels = effectiveSourceWidth / (double)targetWidth;
|
double widthPixels = effectiveSourceWidth / (double)targetWidth;
|
||||||
|
|||||||
@ -18,8 +18,9 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight
|
|||||||
public int OffsetTop { get; set; } = 0;
|
public int OffsetTop { get; set; } = 0;
|
||||||
public int OffsetBottom { get; set; } = 0;
|
public int OffsetBottom { get; set; } = 0;
|
||||||
|
|
||||||
public double MirroredAmount { get; set; } = 0.1;
|
public double MirroredAmount { get; set; } = 10;
|
||||||
|
|
||||||
|
public SmoothMode SmoothMode { get; set; } = SmoothMode.Low;
|
||||||
public BlackBarDetectionMode BlackBarDetectionMode { get; set; } = BlackBarDetectionMode.Bottom;
|
public BlackBarDetectionMode BlackBarDetectionMode { get; set; } = BlackBarDetectionMode.Bottom;
|
||||||
public FlipMode FlipMode { get; set; } = FlipMode.Vertical;
|
public FlipMode FlipMode { get; set; } = FlipMode.Vertical;
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ using Artemis.Profiles.Layers.Abstract;
|
|||||||
using Artemis.Profiles.Layers.Interfaces;
|
using Artemis.Profiles.Layers.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
using Artemis.Profiles.Layers.Types.AmbientLight.AmbienceCreator;
|
using Artemis.Profiles.Layers.Types.AmbientLight.AmbienceCreator;
|
||||||
|
using Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions;
|
||||||
using Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing;
|
using Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing;
|
||||||
using Artemis.ViewModels.Profiles;
|
using Artemis.ViewModels.Profiles;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -56,8 +57,9 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight
|
|||||||
int height = (int)Math.Round(properties.Height);
|
int height = (int)Math.Round(properties.Height);
|
||||||
|
|
||||||
byte[] data = ScreenCaptureManager.GetLastScreenCapture();
|
byte[] data = ScreenCaptureManager.GetLastScreenCapture();
|
||||||
_lastData = GetAmbienceCreator().GetAmbience(data, ScreenCaptureManager.LastCaptureWidth, ScreenCaptureManager.LastCaptureHeight, width, height, properties);
|
byte[] newData = GetAmbienceCreator().GetAmbience(data, ScreenCaptureManager.LastCaptureWidth, ScreenCaptureManager.LastCaptureHeight, width, height, properties);
|
||||||
|
|
||||||
|
_lastData = _lastData?.Blend(newData, properties.SmoothMode) ?? newData;
|
||||||
int stride = (width * ScreenCaptureManager.LastCapturePixelFormat.BitsPerPixel + 7) / 8;
|
int stride = (width * ScreenCaptureManager.LastCapturePixelFormat.BitsPerPixel + 7) / 8;
|
||||||
properties.AmbientLightBrush = new DrawingBrush(new ImageDrawing
|
properties.AmbientLightBrush = new DrawingBrush(new ImageDrawing
|
||||||
(BitmapSource.Create(width, height, 96, 96, ScreenCaptureManager.LastCapturePixelFormat, null, _lastData, stride), new Rect(0, 0, width, height)));
|
(BitmapSource.Create(width, height, 96, 96, ScreenCaptureManager.LastCapturePixelFormat, null, _lastData, stride), new Rect(0, 0, width, height)));
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
using System;
|
||||||
|
|
||||||
|
namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
||||||
{
|
{
|
||||||
public static class PixelDataExtension
|
public static class PixelDataExtension
|
||||||
{
|
{
|
||||||
@ -81,5 +83,25 @@
|
|||||||
|
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] Blend(this byte[] pixels, byte[] blendPixels, SmoothMode smoothMode)
|
||||||
|
{
|
||||||
|
if (smoothMode == SmoothMode.None || pixels.Length != blendPixels.Length) return blendPixels;
|
||||||
|
|
||||||
|
double percentage = smoothMode == SmoothMode.Low? 0.25: (smoothMode == SmoothMode.Medium ? 0.075 : 0.025 /*high*/);
|
||||||
|
|
||||||
|
byte[] blended = new byte[pixels.Length];
|
||||||
|
|
||||||
|
for (int i = 0; i < blended.Length; i++)
|
||||||
|
blended[i] = GetIntColor((blendPixels[i] / 255.0) * percentage + (pixels[i] / 255.0) * (1 - percentage));
|
||||||
|
|
||||||
|
return blended;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte GetIntColor(double d)
|
||||||
|
{
|
||||||
|
double calcF = Math.Max(0, Math.Min(1, d));
|
||||||
|
return (byte)(calcF.Equals(1) ? 255 : calcF * 256);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
namespace Artemis.Profiles.Layers.Types.AmbientLight.Model
|
||||||
|
{
|
||||||
|
public enum SmoothMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Low,
|
||||||
|
Medium,
|
||||||
|
High
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user