Open shayne opened 6 years ago
Also what encoding does the set_icon_from_buffer
expect?
It's useful when you have an icon representation in memory and want to use it. May be useful in cases when the icon is embedded in the executable (so that you don't need to ship a separate icon file) or when you downloaded an icon from internet (or any other similar scenario).
I tried to use it with PNG and ICO files and it worked for me (in Windows and Mac OS).
I tried to use it with PNG and ICO files and it worked for me (in Windows and Mac OS).
Could you please give an example ? I've tried with include_bytes!, with 128*128 ICOs and PNGs, and I always obtain an "Error setting icon from buffer". I tried on Windows.
I also wonder how to do this, I tried with .ico
file, but it doesn't work for me in Windows 10.
let mut systray = systray::Application::new().unwrap();
let icon = include_bytes!("./icon.ico");
systray.set_icon_from_buffer(icon, 64, 64).unwrap();
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: OsError("Cannot load icon from the buffer: 0")', src\main.rs:59:5
I found the bug, this should contain the length:
PR here https://github.com/qdot/systray-rs/pull/45
Btw, if you use VSCode you can monkey patch the systray: Go to definition, then just writing over the file inside the .cargo registry cache. Then just cargo clean
in your project.
I've got some libappindicator updates to bring in too, so I'll try to get this in and get a new release out in the next few days.
Looking at the example we get a reference to
systray::Application
which doesn't haveset_icon_from_buffer
. I see it in mod.rs (on Windows here).