mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +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:
parent
977f88fde9
commit
37d4b31247
@ -1,55 +1,61 @@
|
||||
using System.Drawing;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Devices.Keyboard;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Keyboard.Keys;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Corsair
|
||||
{
|
||||
internal class K95 : KeyboardProvider
|
||||
{
|
||||
private CorsairKeyboard _keyboard;
|
||||
|
||||
public K95()
|
||||
{
|
||||
Name = "Corsair Gaming K95 RGB";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the SDK and sets updatemode to manual as well as the color of the background to black.
|
||||
/// </summary>
|
||||
public override void Enable()
|
||||
{
|
||||
try
|
||||
{
|
||||
CueSDK.Initialize();
|
||||
}
|
||||
catch (CUE.NET.Exceptions.WrapperException){/*CUE is already initialized*/}
|
||||
_keyboard = CueSDK.KeyboardSDK;
|
||||
Height = (int)_keyboard.KeyboardRectangle.Height;
|
||||
Width = (int)_keyboard.KeyboardRectangle.Width;
|
||||
|
||||
_keyboard.UpdateMode = UpdateMode.Manual;
|
||||
_keyboard.Brush = new SolidColorBrush(Color.Black);
|
||||
_keyboard.Update(true);
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
using System.Drawing;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Devices.Keyboard;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Keyboard.Keys;
|
||||
using System;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Corsair
|
||||
{
|
||||
internal class K95 : KeyboardProvider
|
||||
{
|
||||
private CorsairKeyboard _keyboard;
|
||||
|
||||
public K95()
|
||||
{
|
||||
Name = "Corsair Gaming K95 RGB";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the SDK and sets updatemode to manual as well as the color of the background to black.
|
||||
/// </summary>
|
||||
public override void Enable()
|
||||
{
|
||||
try
|
||||
{
|
||||
CueSDK.Initialize();
|
||||
}
|
||||
catch (CUE.NET.Exceptions.WrapperException){/*CUE is already initialized*/}
|
||||
_keyboard = CueSDK.KeyboardSDK;
|
||||
Height = (int)_keyboard.KeyboardRectangle.Height;
|
||||
Width = (int)_keyboard.KeyboardRectangle.Width;
|
||||
|
||||
// _keyboard.UpdateMode = UpdateMode.Manual;
|
||||
_keyboard.Update(true);
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="bitmap//"></param>
|
||||
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));
|
||||
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();
|
||||
}
|
||||
@ -74,6 +80,6 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
_keyboard.DetachKeyGroup(ledGroups[x, y]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user