GithubHelp home page GithubHelp logo

Comments (15)

DarthAffe avatar DarthAffe commented on June 12, 2024 1

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.

RobertBeekman avatar RobertBeekman commented on June 12, 2024

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.

DarthAffe avatar DarthAffe commented on June 12, 2024

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.

RobertBeekman avatar RobertBeekman commented on June 12, 2024

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.

DarthAffe avatar DarthAffe commented on June 12, 2024

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.

RobertBeekman avatar RobertBeekman commented on June 12, 2024

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.

DarthAffe avatar DarthAffe commented on June 12, 2024

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.

RobertBeekman avatar RobertBeekman commented on June 12, 2024

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.

DarthAffe avatar DarthAffe commented on June 12, 2024

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.

RobertBeekman avatar RobertBeekman commented on June 12, 2024

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.

DarthAffe avatar DarthAffe commented on June 12, 2024

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.

RobertBeekman avatar RobertBeekman commented on June 12, 2024

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.

RobertBeekman avatar RobertBeekman commented on June 12, 2024

This works well for us, so I reckon you can close it, Hazard is too forgetful to do so :P

from cue.net.

loganintech avatar loganintech commented on June 12, 2024

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.

DarthAffe avatar DarthAffe commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.