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
PeterPosted Oct 27, 2008, 3:15 AM
Kirtan PatelPosted Oct 26, 2008, 6:08 PM
http://www.geekpedia.com/tutorial219_Extracting-Icons-from-Files.html
Ashley ArgilePosted Oct 26, 2008, 5:58 AM
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