Hi.
Iwould like to extract an icon from an .exe file. currently I am doing it like this:
System.Drawing.Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(exePath);
MemoryStream Memo = new MemoryStream();
ico.Save(Memo);
FileStream fs = System.IO.File.OpenWrite(icoOutputPath);
fs.Write(Memo.GetBuffer(), 0, (int)Memo.Position);
fs.Close();
I works fine, but the quality of the icon is very bad. The colors are not the same as the ones on the .exe file.
Any ideas on how to preserve the quality?
Thanks in advance.
Peter

Ashley Argile97 reputationPosted Oct 26, 2008, 1:58 AM EDT
The problem that you have is that the Save method on the Icon class can only write 16-bit colours. This is because of a limitation in the Encoder provided by .NET, as detailed in this KnowledgeBase article. There's a project called Icon Explorer that contains a class called IconEx that will allow you to do what you want. It can be found here. Not sure how the licensing works for it though.
Regards
Ashley
Kirtan PatelRank #292 · 8.6K reputationPosted Oct 26, 2008, 2:08 PM EDT
http://www.geekpedia.com/tutorial219_Extracting-Icons-from-Files.html
Peter16 reputationPosted Oct 26, 2008, 11:15 PM EDT