Skip to content
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

Allowing Base64Encoded Images #4

Closed
Tylerjet opened this issue Jul 1, 2021 · 8 comments
Closed

Allowing Base64Encoded Images #4

Tylerjet opened this issue Jul 1, 2021 · 8 comments

Comments

@Tylerjet
Copy link

Tylerjet commented Jul 1, 2021

when packaging with pkg the module cannot find the image in the virtual snapshot path and being able to use a base64Encoded string for the image would help that issue if possible.

@simonbuchan
Copy link
Owner

Unfortunately, this would be a bit of a pain in the ass to do.

At the moment images are loaded by windows using LoadImageW here:

auto icon = (HICON)LoadImageW(hinstance, path, IMAGE_ICON, size.width,
size.height, flags);

So I can't really control how it loads from a path, using that.

To do this properly, I could add an implementation using something like CreateIconFromResourceEx which, as the name implies, takes the icon resource bits, which are different than what's in an .ico file: specifically, it only includes one "size" of the .ico file, see this stack-overflow answer for some code. So if you just want to give me a .ico file content, I would also have to reproduce the windows size lookup behavior, which I don't think is particularly well documented?

That said, for this purpose you may instead load from a windows resource of the current executable, using Icon.loadResource(size, resource_id), possibly using rcedit to embed the icon resource after packaging, but this needs to be run on Windows, which is annoying for CI.

@Tylerjet
Copy link
Author

Tylerjet commented Jul 1, 2021

Ahh ok thanks for the info, i do already have a workflow for changing the default icon for the executable using resource hacker would the id i set the icon be the same i use for the resource_id if i was using rcedit as well? If so i will definitely use that way instead as it will save me a bunch of time.

@simonbuchan
Copy link
Owner

Yep, though it looks like only number ids are supported at the moment, sorry!

@simonbuchan
Copy link
Owner

Note that rcedit is simply an example of a tool to edit the resources, you should be able to use Resource Hacker for this too, if you prefer.

@simonbuchan
Copy link
Owner

One more thing, IIRC, it would be the id of the ICONGROUP resource, not the individual ICON.

@Tylerjet
Copy link
Author

Tylerjet commented Jul 1, 2021

Awesome yeah i was about to ask that when going through all the ids i currently see when just opening the exe in resource hacker ill def test it later today and see if it works out

@Tylerjet
Copy link
Author

Tylerjet commented Jul 1, 2021

Absolutely perfect! Worked like a charm and you are indeed correct it is the icongroup id.
Closing as this solution is far better than original request

@Tylerjet Tylerjet closed this as completed Jul 1, 2021
@simonbuchan
Copy link
Owner

Glad it worked out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants