1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Added color reset for pixels that shouldn't be lit. It seems like the resize in the bitmap constructor is not high quality, research is needed.

This commit is contained in:
Logan Saso 2016-02-05 00:16:35 -08:00
parent 977f88fde9
commit 37d4b31247

View File

@ -4,6 +4,7 @@ using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard; using CUE.NET.Devices.Keyboard;
using CUE.NET.Brushes; using CUE.NET.Brushes;
using CUE.NET.Devices.Keyboard.Keys; using CUE.NET.Devices.Keyboard.Keys;
using System;
namespace Artemis.KeyboardProviders.Corsair namespace Artemis.KeyboardProviders.Corsair
{ {
@ -30,8 +31,7 @@ namespace Artemis.KeyboardProviders.Corsair
Height = (int)_keyboard.KeyboardRectangle.Height; Height = (int)_keyboard.KeyboardRectangle.Height;
Width = (int)_keyboard.KeyboardRectangle.Width; Width = (int)_keyboard.KeyboardRectangle.Width;
_keyboard.UpdateMode = UpdateMode.Manual; // _keyboard.UpdateMode = UpdateMode.Manual;
_keyboard.Brush = new SolidColorBrush(Color.Black);
_keyboard.Update(true); _keyboard.Update(true);
} }
@ -43,13 +43,19 @@ namespace Artemis.KeyboardProviders.Corsair
/// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap size. /// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap size.
/// Does not reset the color each time. Uncomment line 48 for collor reset. /// Does not reset the color each time. Uncomment line 48 for collor reset.
/// </summary> /// </summary>
/// <param name="bitmap"></param> /// <param name="bitmap//"></param>
public override void DrawBitmap(Bitmap bitmap) public override void DrawBitmap(Bitmap bitmap)
{ {
//bitmap = new Bitmap(@"C:\Users\Hazard\Desktop\1920x1080.png");
Bitmap resize = new Bitmap(bitmap, new Size((int)_keyboard.KeyboardRectangle.Width, (int)_keyboard.KeyboardRectangle.Height)); Bitmap resize = new Bitmap(bitmap, new Size((int)_keyboard.KeyboardRectangle.Width, (int)_keyboard.KeyboardRectangle.Height));
foreach (var item in _keyboard.Keys) foreach (var item in _keyboard.Keys)
{ {
item.Led.Color = resize.GetPixel((int)item.KeyRectangle.X, (int)item.KeyRectangle.Y); Color pixelColor = resize.GetPixel((int)item.KeyRectangle.X, (int)item.KeyRectangle.Y);
if (pixelColor.Name == "0")
{
pixelColor = Color.Black;
}
item.Led.Color = pixelColor;
} }
_keyboard.Update(); _keyboard.Update();
} }