dwmkerr / sharpshell

SharpShell makes it easy to create Windows Shell Extensions using the .NET Framework.
MIT License
1.51k stars 260 forks source link

Icon Overlay only returns one image, but multiple are needed for different sizes. #119

Open markmnl opened 8 years ago

markmnl commented 8 years ago

SharpIconOverlayHandler.GetOverlayIcon(); returns a System.Drawing.Icon which only contains one image at one size.

Problem is based on Windows Explorer view settings (e.g. tiles, small, medium, large, details etc.) a different sized icon should be used for the same overlay and there is no way to provide this in SharpShell.

markmnl commented 8 years ago

FWIW I have found using a 128x128 image with some padding to work well - it is scaled automatically for other resolutions.

KeithLRobertson commented 8 years ago

One .ico file can contain images of several sizes, and Explorer will choose the appropriate one depending on its view setting. Even passed through Icon, this is working. Find a good tool for creating .ico files with multiple images; I forgot what we used for that.

We embed several of these in our executable using the InsertIcons tool.

markmnl commented 8 years ago

While an .ico file contains multiple (I use Gimp to create mine) all the methods to create System.Drawing.Icon from an .ico choose only one of those images.

I suspect Windows explorer then scales that one image it has which is why it appears to work for you.

Thus using one higher res image with padding (otherwise the whole icon is covered for smaller views) seems to work best, but its still not perfect.

KeithLRobertson commented 8 years ago

Ah, yes, you're absolutely right. The reason it works for me is because I discovered this problem a long time ago and worked around it, and I have since forgotten about it. :-)

BaseIconOverlayHandler.cs may help you.

JereckNET commented 5 months ago

Thanks @KeithLRobertson, your workaround is still useful 8 years later !

For those interested, here is an icon file with visually different pictures that I usually use when checking which resolution is used : MultiSize.zip

For information on Windows 10 here are the resolution used by each explorer view for the overlays and the base icons :

View Base icon Overlay icon
List / Details / Small 16x16 16x16
Content 32x32 32x32
Medium / Tiles 48x48 32x32
Large 256x256 48x48
Extra Large 256x256 256x256