It is currently March 29th, 2024, 12:50 pm

[Suggestion] Icon image support

Report bugs with the Rainmeter application and suggest features.
User avatar
Socks the Fox
Posts: 104
Joined: August 25th, 2015, 6:40 pm

[Suggestion] Icon image support

Post by Socks the Fox »

I've recently developed a plugin that, among other things, can support reading colors from icons and make them available to skins. Unfortunately, I feel this feature is a bit hampered by Rainmeter's inability to display icons. It's actually not that complicated to make a HBITMAP from an icon:

Code: Select all

HICON hIcon = nullptr;
ICONINFO icon;
IImageListPtr spiml;
int iconSize = SHIL_EXTRALARGE;
if (IsWindowsVistaOrGreater())
{
	iconSize = SHIL_JUMBO;
}

// Find the proper icon to use.
// I was dreading this part until I found out it's
// literally three functions.
SHGetFileInfo(path, 0, &info, sizeof(info), SHGFI_SYSICONINDEX);
SHGetImageList(iconSize, IID_PPV_ARGS(&spiml));
spiml->GetIcon(info.iIcon, ILD_TRANSPARENT, &hIcon);

// Load icon image data
GetIconInfo(hIcon, &icon);

// At this point `icon` contains hbmColor which *should* contain the color
// bitmap info, including an alpha channel if present. Bonus points: supports
// .exe & .ico, and offers a sane default for any file type GDI+ doesn't handle
Author of Chameleon :: Like my plugin? Consider donating! I don't need much :3
User avatar
Virginityrocks
Posts: 478
Joined: February 26th, 2011, 10:22 pm

Re: [Suggestion] Icon image support

Post by Virginityrocks »

I'm using .ICO files in Rainmeter no problem right now.
User avatar
exper1mental
Posts: 269
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University

Re: [Suggestion] Icon image support

Post by exper1mental »

Virginityrocks wrote:I'm using .ICO files in Rainmeter no problem right now.
I'd need to check again (I avoid using ICO files with Rainmeter when possible) but as I recall .ICO files turn out blurry with Rainmeter for some reason, and Rainmeter doesn't seem to take advantage of .ICO files with multiple images of different resolutions inside. Perhaps one of those things is the issue they are talking about? :???:
Image
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Suggestion] Icon image support

Post by jsmorley »

User avatar
Socks the Fox
Posts: 104
Joined: August 25th, 2015, 6:40 pm

Re: [Suggestion] Icon image support

Post by Socks the Fox »

Okay. So Rainmeter can display .ico icons! That's good, but based on what I'm reading it does so poorly. The code I provided automatically picks the best icon it can.

Rainmeter also doesn't seem to support icons from .exe files (which is the main use case I was going for). It seems incredibly stupid to make end users do the work of extracting the icon for every .exe file they might possibly want to use in a skin, that could just as easily be accomplished with a bit of code in RM.

It also doesn't seem to support grabbing the previews from .pdf, .doc, .whatever that the code I posted does.

So what would it take to get this integrated into Rainmeter?
Author of Chameleon :: Like my plugin? Consider donating! I don't need much :3
User avatar
Brian
Developer
Posts: 2674
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Suggestion] Icon image support

Post by Brian »

Socks the Fox wrote:Okay. So Rainmeter can display .ico icons! That's good, but based on what I'm reading it does so poorly.
Rainmeter supports .ico files just fine except when using an ImageTint property in some cases. The problem was already discussed in that other thread, so no need to re-hash that here.

Socks the Fox wrote:Rainmeter also doesn't seem to support icons from .exe files (which is the main use case I was going for). It seems incredibly stupid to make end users do the work of extracting the icon for every .exe file they might possibly want to use in a skin, that could just as easily be accomplished with a bit of code in RM.
The FileView plugin does this.

Socks the Fox wrote:It also doesn't seem to support grabbing the previews from .pdf, .doc, .whatever that the code I posted does.
I haven't tested this, but since your code is really similar to the code used in FileView, I would assume this works with the FileView plugin as well.

Socks the Fox wrote:So what would it take to get this integrated into Rainmeter?
The FileView plugin actually uses code similar to this, although the image meter does not - mainly because the code we use works for many image formats others than .ico (even though we still have the outstanding issue described above).


So, basically, we already do everything you have asked for with the small exception of using ImageTint on certain .ico files - which was described in another thread.

-Brian
User avatar
Socks the Fox
Posts: 104
Joined: August 25th, 2015, 6:40 pm

Re: [Suggestion] Icon image support

Post by Socks the Fox »

That seems... drastically overcomplicated for the sole purpose of displaying some icons. Is there no benefit to simplifying this? I can't be the only one who thought RM couldn't do this due to the non-intuitive way it has to be done.

If I were implementing this I'd have the Image meter try and create an image the current way, then only if that fails use the above to grab the icon. Backwards compatible and offers better failure handling than just a blank space where the user expects an image.
Author of Chameleon :: Like my plugin? Consider donating! I don't need much :3
User avatar
Brian
Developer
Posts: 2674
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Suggestion] Icon image support

Post by Brian »

I am really not understanding the complaint here.

An image meter displays images. Nearly all images anyone would want to display come in the various image formats the image meter supports (ico, jpg, png, gif, tif, bmp, etc.).

If someone really wants to display the icon associated with a file, the FileView plugin can do this. It might be somewhat a little more complicated, but it really isn't that bad.

Are you proposing that we change the image meter to automatically extract the icon associated with a file that is not one of the already defined types?

So, ImageName=SomePath\SomeFile.exe would display the icon associated with the .exe instead of failing?

I would vote against this as, in my opinion, hardly anyone would use it this way, and it can already be done with the help of the FileView plugin. Rainmeter isn't really meant to be some shell replacement. (However, I am just 1 member of the team. If the rest of team likes it, then so be it.)

-Brian
User avatar
Socks the Fox
Posts: 104
Joined: August 25th, 2015, 6:40 pm

Re: [Suggestion] Icon image support

Post by Socks the Fox »

Brian wrote: Are you proposing that we change the image meter to automatically extract the icon associated with a file that is not one of the already defined types?

So, ImageName=SomePath\SomeFile.exe would display the icon associated with the .exe instead of failing?
Essentially, yes. It seems asinine to bring in an entire extra plugin, read the exe from the disk to extract the icon, write that icon to disk, read that icon from the disk, then parse and display it.

I see an awful lot of skins out there that amount to docks, launchers, etc. that could use a simplified way to display icons.

I'd be more than happy to take the time to write the code and submit a pull request if needed.
Author of Chameleon :: Like my plugin? Consider donating! I don't need much :3
User avatar
Brian
Developer
Posts: 2674
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Suggestion] Icon image support

Post by Brian »

Socks the Fox wrote:I'd be more than happy to take the time to write the code and submit a pull request if needed.
I don't think that will be necessary. The code is already in FileView. If we decide to extend this to the Image meter, we can just copy/paste/modify the FileView code since it is a little more complete due to the handling of some special filetypes (like .url).

-Brian