Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

How to use set_icon_from_buffer #24

Open
shayne opened this issue Jan 6, 2018 · 6 comments
Open

How to use set_icon_from_buffer #24

shayne opened this issue Jan 6, 2018 · 6 comments

Comments

@shayne
Copy link

shayne commented Jan 6, 2018

Looking at the example we get a reference to systray::Application which doesn't have set_icon_from_buffer. I see it in mod.rs (on Windows here).

@shayne
Copy link
Author

shayne commented Jan 6, 2018

Also what encoding does the set_icon_from_buffer expect?

@daniel-abramov
Copy link
Contributor

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).

@nicolasbauw
Copy link

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.

@Ciantic
Copy link

Ciantic commented Jul 9, 2020

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

Ciantic added a commit to Ciantic/systray-rs that referenced this issue Jul 9, 2020
Fix the set resource bug qdot#24
@Ciantic
Copy link

Ciantic commented Jul 9, 2020

I found the bug, this should contain the length:

PR here #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.

@qdot
Copy link
Owner

qdot commented Jul 9, 2020

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.

rafamerlin pushed a commit to rafamerlin/systray-rs that referenced this issue Aug 24, 2020
Fix the set resource bug qdot#24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants