Comments (15)
The new package is on nuget.org now.
Just apply an ImageBrush to the keyboard and set the Image-Property before updating.
Since it's currently stretching the image to fit on the keyboard, a 25*7 image might not look as expected on smaller keyboards (k70, k65). I'll work but some keys will get the same color. A smaller image would of course fix this.
I hope this is what you need :p
from cue.net.
It needs some looking in to, it's because for Corsair the image is being upscaled to something like 480x170, because that's how the keys coordinates are defined.
It would be better if we'd downscale the keys instead, we'd only have to do that once, not every frame
from cue.net.
I've looked into mapping images to the keyboard a while ago but dropped the idea since i wasn't happy with my ideas of mapping pixels to the keys. Most of the keys aren't strictly in lines and averaging everything over the key would lead to a mess (most of the time) even if weighted.
If you tell me what kind of "mapping" you need, I can give you a example of what I think would be best for the corsair.
from cue.net.
I was thinking of something like this: http://i.imgur.com/bbGmhD9.png
So, define a grid based on the number keys (and for the K95 the macro keys) and just fill the other keys if they are inside of the colored cells for more than 50%
It would be really nice if we could pass a bitmap that's the size of that grid (25x7 in this case). We wouldn't need any kind of key-averaging/smoothing, that can be done by ourselves when drawing the bitmap
from cue.net.
Well, I think I got it (at least that 'pixel-perfect' approach). There's only one problem: On my keyboard (german layout) the 'Ö'- and 'Ä'- key are snapping to the same pixel. I thought this would be extremely unlikely but since it's quite hard to debug I'll ignore this for now.
The thing which prevents me from just posting my solution here is, that I just found quite a big calculation bug which I need to fix to make it work. I'll try to get out a version in the next hour.
from cue.net.
It works well, but we use a lot of transparancy which seems to be ignored.
The workaround we had for that was this:
item.Led.Color = Color.FromArgb(255, (int) (col.R/255.00*col.A), (int) col.G/255.00*ledColor.A), (int) (col.B/255.00*col.A));
But since we're no longer assigning the LEDs ourselves, that won't work anymore.
from cue.net.
Well, this is somehow tricky - transparency works as expected which leads to your problem:
You are setting the "background of the keyboard" (keyboard.Brush). Since there is nothing behind Transparency has no effect (the color is transparent but nothing [nothing != black - i think that's what you expected] shines through).
To fix this you should set the background to black and applying the brush to a group containing all keys:
keyboard.Brush = new SolidColorBrush(Color.Black);
ImageBrush imageBrush = new ImageBrush();
IKeyGroup grp = new ListKeyGroup(keyboard, keyboard.Keys.ToArray());
grp.Brush = imageBrush;
imageBrush.Image = (Bitmap)Image.FromFile("testimage.png");
keyboard.Update();
from cue.net.
Ah makes sense,
I tried your code but that gave me 30% CPU usage and didn't clear old frames :o
But with your explanaition I was able to come up with this:
var fixedBmp = new Bitmap(bitmap.Width, bitmap.Height);
using (var g = Graphics.FromImage(fixedBmp))
{
g.Clear(Color.Black);
g.DrawImage(bitmap, 0,0);
}
var brush = new ImageBrush
{
Image = ImageUtilities.ResizeImage(fixedBmp, Width, Height)
};
_keyboard.Brush = brush;
_keyboard.Update();
Thanks!
from cue.net.
Hmm, the high cpu-usage is interesting. This needs investigation, but if it works with the code you posted I'll leave that for tomorrow.
from cue.net.
Oh now it's great, 0-1% . It was just the little code snippet you posted that was causing it for me
from cue.net.
Ah, just to be sure: You did create the keygroup and the brush once, stored it anywhere and just updated the image-property in a loop?^^
The creation of the group might be expensive but needs to be done only once.
(That's the case for the brush in your snippet too)
from cue.net.
Oh no, sorry I was creating it every frame, most likely that was it then. I'll move the brush from my snippet somwhere else too
from cue.net.
This works well for us, so I reckon you can close it, Hazard is too forgetful to do so :P
from cue.net.
Scandalous I thought I did close it
Please excuse typos as this was sent from my iPhone
On Jun 3, 2016, at 3:50 AM, Robert Beekman [email protected] wrote:
This works well for us, so I reckon you can close it, Hazard is too forgetful to do so :P
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
from cue.net.
Ah nvm - I'll leave it open as a reminder until I merge from the dev-branch back to main - I'm working on some improvements here.
from cue.net.
Related Issues (20)
- Uninitialize or Shutdown functionality HOT 4
- Test development-changes with all devices HOT 6
- [1.0.0] Keyboard DeviceRectangle size HOT 3
- Using CUE.NET with CUE2 keyboard keys go to white when calling update() HOT 4
- Update Wiki
- Profile-API isn't able to find CUE2 profiles
- CUE.NET Does not initialize for some users HOT 5
- Memory leaks when using LED groups and brushes HOT 18
- K95 Platinum lightbar support HOT 8
- Load SDK dll from different location HOT 4
- VOID Wireless bug and feature request HOT 2
- Keys which don't exist on a physical device (ie. Macro keys) throws null reference HOT 4
- Locking the PC stops updates (sometimes) HOT 6
- HELP NEEDED: How to keep LED changes active after running application? HOT 2
- UWP Compatibility HOT 12
- CueSDK.Reinitialize never returns HOT 1
- Can't update Key Colors individually unless Brush is applied. HOT 4
- Calling EnableKeypressCallback() more than once causes duplicated events and GC/NRE issues
- Can't read color without device freezing
- Corsair keyboard K70 MK.2 RGB HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cue.net.