Skip to content

Commit f209196

Browse files
authored
Improved support for Chroma Link (#36)
1 parent 017cd0e commit f209196

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

Ambilight/Logic/LinkLogic.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,33 @@ public LinkLogic(TraySettings settings, IChroma chromaInstance)
2929
/// <param name="newImage">ScreenShot</param>
3030
public void Process(Bitmap newImage)
3131
{
32-
Bitmap map = ImageManipulation.ResizeImage(newImage, 2, 2);
32+
Bitmap map = ImageManipulation.ResizeImage(newImage, 4, 1);
3333
map = ImageManipulation.ApplySaturation(map, _settings.Saturation);
34-
GenerateLinkGrid(map);
35-
34+
35+
ApplyImageToGrid(map);
36+
ApplyC1(ImageManipulation.ResizeImage(map, 1, 1));
3637
_chroma.ChromaLink.SetCustomAsync(_linkGrid);
38+
map.Dispose();
39+
}
40+
41+
private void ApplyC1(Bitmap map)
42+
{
43+
Color color = map.GetPixel(0,0);
44+
_linkGrid[0] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B);
3745
}
3846

3947
/// <summary>
4048
/// From a given resized screenshot, an ambilight effect will be created for the keyboard
4149
/// </summary>
4250
/// <param name="map">resized screenshot</param>
43-
private void GenerateLinkGrid(Bitmap map)
51+
private void ApplyImageToGrid(Bitmap map)
4452
{
4553
//Iterating over each key and set it to the corrosponding color of the resized Screenshot
46-
for (var r = 1; r <= 2; r++)
54+
for (int i = 1; i < Colore.Effects.ChromaLink.ChromaLinkConstants.MaxLeds; i++)
4755
{
48-
for (var c = 0; c < 2; c++)
49-
{
50-
System.Drawing.Color color;
51-
color = map.GetPixel(c, r-1);
52-
if (r == 2) r++;
53-
_linkGrid[c + r] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B);
54-
if (r > 2) r--;
55-
}
56+
Color color = map.GetPixel(i-1,0);
57+
_linkGrid[i] = new ColoreColor((byte)color.R, (byte)color.G, (byte)color.B);
5658
}
57-
_linkGrid[0] = _linkGrid[1];
5859
}
5960
}
6061
}

0 commit comments

Comments
 (0)