- NSIS Discussion
- Shortcut icons seem corrupted
Archive: Shortcut icons seem corrupted
MidnightJava
5th February 2008 03:06 UTC
Shortcut icons seem corrupted
I must be missing something basic, because it seems very straightforward to make icons work, but I can't get them to work for shortcuts.
I have an icon file, ec_icon.ico, which I created with an icon editor. It was made from a 16 x 16 .gif file, and the icon for the icon file looks as expected in Windows Explorer. Also, I use this icon for the installer icon, via
Icon ec_icon.ico
and it looks fine in the installer window.
But then I try to use the same icon file as the QuickLaunch icon, with the following NSIS commands in the installer Section
SetOutPath $INSTDIR
File "ec_icon.ico"
CreateShortcut "$QUICKLAUNCH\$(^Name).lnk" "$INSTDIR\ec.exe" "" "$INSTDIR\ec_icon.ico"
An icon shows up in the QuickLaunch tray, but it's pretty much just garbage. It's not a default icon, it's just a corrupted image. I tried setting an icon index of 0 or 1 in the CreateShortcut command (there is only one image in the.ico file), but then I get a default icon in the QuickLaunch tray.
Can someone please tell me what I'm missing?
pospec
5th February 2008 05:33 UTC
What is the .ICO filesize?
MidnightJava
5th February 2008 06:12 UTC
1 KB
pospec
5th February 2008 06:14 UTC
Icons for installer have to be 766 B. Maybe you'll need two icons - one for installer and one for that quicklaunch shortcut.
MidnightJava
5th February 2008 06:29 UTC
Do you mean put two image sin one .ico file? I put one 16 x 16 andone 32 x 32 .gif in the .ico file, and now the size is 766 B. (Previously it was half this value. 1 KB was the rounded value in Explorer; I didn't know you wanted the precise value.)
Anyway I still have the problem. Only now the "good" icon is displaying in gray scale, where it used to display in color. By "good" icon, I mean the one that displays in th Installer window, the icon for the .ico file itself, and also the uninstaller icon (both in the start menu shortcut and on the uninstaller.exe file).
All the other icons (Quicklaunch and in the start menu) are displayed in gray scale and also distorted to the point of being unrecognizable.
edit: I also should mention, the color depth when I created the .ico file was 8 bit. But I bumped it to 32 bit, and still the icon displays in gray scale.
pospec
5th February 2008 06:31 UTC
I mean two .ico files in your installer - one file for the shortcut and one embeded in installer.
MidnightJava
5th February 2008 06:57 UTC
I'm not sure I understand the distinction you;re making. So the one .ico is included in the installer via the File command. And then I reference it in the dir $INSTDIR via the CreateShortcut command. Now what it does it mean in distinction from this to have one ,ico file "emebedded in installer"?
I deleted my icon cache file and rebooted. Now all icons are behaving the same-- gray scale, but no longer distorted. But all other icons, for other programs, are displaying in color.
pospec
5th February 2008 07:06 UTC
That quicklaunch icon has nothing to do with installer icon (via Icon instruction - that's why I write embeded). Choose such quicklaunch icon, that looks well, pack it with File instruction, extract somewhere (e.g. $INSTDIR) and you're done.
MidnightJava
5th February 2008 12:50 UTC
OK I see what you were saying, and that's what I did. I embedded the icon file, and extracted it into $INSTDIR. This is the file I point to with the QL shortcut.
I used a separate copy of the same icon file as the installer icon. I was doing this originally just to verify that the icon was built properly, especially when the icon was looking right in the installer and uninstaller shortcut, but looking wring in other locations.
Now the icons are gray scale in every case relating to NSIS, but if I edit them with a resource editor, they're in color. So I remain baffled.
pospec
5th February 2008 12:54 UTC
What if you create that QL shortcut MANUALLY and set it's icon to that 766 B .ico? I mean that you could use two DIFFERENT files, one which fit in installer and one which fit in QL shortcut. I can't help you further.
Afrow UK
5th February 2008 14:08 UTC
Explorer can show icons if they are just bitmaps renamed to .ico. My bet is you haven't converted your gif images over to ico properly.
Stu
MidnightJava
6th February 2008 04:02 UTC
Yes, the icon file became invalid at some point. That was causing the gray scale effect. Also icon caching was apparently causing confusion. I no longer see an icon cache file to delete as I did once, but still have to reboot every time I change the icon.
Now I have a .ico file with 16, 32, and 48 bit .bmp images, each at 4, 8, and 24 bit color depths, and with colors from the MS icon color palette. The behavior with this file is consistent, but still bad. The color shows up, but the image is all jumbled up.
I display the same image directly as an icon, using Java to place it in the system tray or the Window title bar or the task bar, and it looks fine. But when I display it as a .ico file, created to MS specs for resolution and color depth, it's unrecognizable. This is not an NSIS problem. Apparently MS icons are very hard to get right. I did this in about 30 seconds on the Mac.
Anders
6th February 2008 07:35 UTC
could you post this icon so we can take a look at it, might be a problem with your editor
MidnightJava
6th February 2008 15:49 UTC
icon file uploads are not permitted for the site, so I posted it here
I posted a link to the icon file and to the bmp file as well, so you can see what the image is supposed to look like.
I used "XN Resource Editor" to create the icon from bmp files. I put 9 different bmp files into the icon file. I provided 16x16, 32x32, and 48x48 resolution images, each with 4-bit, 8-bit, and 32-bit color depth. The bmp files have only two colors in them, with RGB values from the MS color palette for icons. This is in accordance with what I read here
It does look like the bmp files are not being extracted properly from the .ico file, but I don't know why.
Anders
6th February 2008 16:22 UTC
There has to be a problem with the way you create the icon, there are several free icon editors out there, give one of them a try,
http://icofx.*********/
or
http://greenfish.extra.hu/downloads.php
to name just two
MidnightJava
6th February 2008 22:00 UTC
Thanks for the icon editor suggestions. I wasn't able to find anything with Google except XN Resource Editor, which seems to fail completely, at least wrt creating icons.
I downloaded both editors you recommended, and they seem to do the job properly. At least the icon for the icon file itself looks right, and I can open the icon file with both editors and see all 9 images with the proper resolutions and color depths.
But the icon still doesn't look right after creating with NSIS. The old gray scale icon shows up instead of the color one. For example, I create the QuickLaunch icon with
CreateShortcut $QUICKLAUNCH\$(^Name).lnk "$INSTDIR\ec.exe" "" "$INSTDIR\ec_icon.ico"
after having put the icon file in the install dir via
SetOutPath $INSTDIR
File "ec_icon.ico"
But then the QL icon is gray scale. This happens with start menu icons as well.
I thought perhaps I need to supply an icon index number in the CreateShortcut command, but I don't see any index numbers identifying the icon images with either editor. I tried using 1, 2,3...9 for icon indices, but when I do that NSIS fails to find the icon altogether.
For some reason NSIS seems to be causing the icon to be rendered with 1-bit color depth. I followed prospec's suggestion and manually configured a QuickLaunch item to point to the same icon file, and then it's rendered properly in the QuickLaunch tray. I also tried the following for creating the QL shortcut
CreateShortcut "$SMPrograms\$StartMenuGroup\$(^Name).lnk" "$INSTDIR\ec.exe" "" "ec_icon.ico"
so I point directly to the icon file instead of extracting it from the installer executable. In this case I get the gray scale icon image as well. So I seem to be close, but I remain flummoxed.
BTW, I posted the new version of the icon file, created with IcoFX,
here
MidnightJava
7th February 2008 21:30 UTC
It looks like icon caching was responsible for the remaining problem. I had deleted $APPDATA\IconCache.db earlier to remove cached icons, but it never re-appeared and yet icons are being cached somewhere. Renaming the icon made it display properly, and then after a reboot I could use the old name again.
Thanks for all the help, especially the pointer to icon editors that actually work. XN Resource Editor really caused a lot of problems, and the Windows mysterious icon caching scheme made a bad situation worse.
GregL
26th February 2008 16:12 UTC
Try adding RefreshShellIcons?
meaningoflights
5th August 2008 11:10 UTC
Desktop Icon Remains
I experienced a similar issue where the desktop icon and StartMenu folder remained after uninstall.
I implemented http://nsis.sourceforge.net/Refresh_Desktop and that didn't make a difference.
The problem was that I had installed the app under different users, hence putting:
SetShellVarContext all
in the uninstall section resolved my issue:)
HTH someone else
Comperio
5th August 2008 15:07 UTC
Speaking of icon editors... For a very quick slap-it-together type of icon editor, I have not found any better than Icon Susuhi
I know the name sounds real cheesy, but it works great and it's free.