Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load icon from a file? #1170

Closed
daladim opened this issue Dec 26, 2021 · 2 comments
Closed

Load icon from a file? #1170

daladim opened this issue Dec 26, 2021 · 2 comments

Comments

@daladim
Copy link
Contributor

daladim commented Dec 26, 2021

Thanks for iced.

I'm using iced to make a native (Windows and Linux if that matters) app, and I'd like to give its window an icon.
I managed to add an icon using Icon and passing it to my app's settings.

Is there a way (I haven't found in the doc, but I may not have been looking at the right places) to load an icon from a file, instead of giving a pre-computed array of pixels?

Especially, I'd like to load an SVG icon. Since you already provide SVG widgets. I haven't read its source code yet, but maybe this could be somehow reused so that we could provide an Icon::from_file(), or at least Icon::from_svg().
What do you think? Would that make sense?
Is there an easy way to rasterize an SVG into a pixel array already, and would it be better suited to build the array first, then give it to Icon::from_rgba?

I could help and make the MR myself, once you tell me what solution sounds the most sensible to you.
Thanks

@daladim
Copy link
Contributor Author

daladim commented Dec 26, 2021

How does svg::Handle::data() relates to an RGBA array?

@13r0ck
Copy link
Member

13r0ck commented Dec 27, 2021

This is how I did it in my project

  1. first create the icon data
  2. pass that into the iced window

@hecrj hecrj closed this as completed Jan 22, 2022
@iced-rs iced-rs locked and limited conversation to collaborators Jan 22, 2022
@hecrj hecrj converted this issue into discussion #1216 Jan 22, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants