<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Mon, 20 May 2013 21:20:02 GMT</pubDate>
	<lastBuildDate>Mon, 20 May 2013 21:20:02 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>12</c9:totalResults>
	<c9:pageCount>-12</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p>The following code fails to create a valid icon recognized by Windows Explorer or VS2005; though, it can be opened in Paint.<br>
<br>
using (Bitmap bmp = new&nbsp;Bitmap(@&quot;C:\ABitmap.bmp&quot;))<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bmp.Save(@&quot;C:\IconFromBitmap.ico&quot;, ImageFormat.Icon);<br>
}<br>
<br>
After googling, a post in MSDN forum was found with similar problem <a href="http://forums.microsoft.com/msdn/showpost.aspx?postid=63447&amp;siteid=1">
http://forums.microsoft.com/msdn/showpost.aspx?postid=63447&amp;siteid=1</a><br>
<br>
The code seems rather straight-forward but it does not appear to do the job. <br>
<br>
Does anyone have a solution?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/130238#130238</link>
		<pubDate>Sun, 06 Nov 2005 04:08:13 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/130238#130238</guid>
		<dc:creator>Mar7in</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Mar7in/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p>It's a known bug. The .NET GDI doesn't even have an icon encoder so it saves it as a png file. I was trying to find a solution for that for a long time and the only thing I've found is that you can use a free image conversion library called FreeImage (
<a href="http://freeimage.sourceforge.net/">http://freeimage.sourceforge.net/</a>&nbsp;) which can save images to many different icons. It's free and released under the GNU license if I'm not mistaken, but there's one limit - it can save icons only in this size
 range: 16x16 - 128x128 . So keep in mind that smaller or bigger images won't be saved.<br>
<br>
<br>
If you find a better solution please share it with us. I'd really like to know how to solve it without using an external source.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/dc565d9aed1f44f1b5119dea012f0eb1#dc565d9aed1f44f1b5119dea012f0eb1</link>
		<pubDate>Sun, 06 Nov 2005 14:32:45 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/dc565d9aed1f44f1b5119dea012f0eb1#dc565d9aed1f44f1b5119dea012f0eb1</guid>
		<dc:creator>yyy</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/yyy/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p>Since *.ico files are simply binary files containing an embedded resource list containing bitmap icons.<br>
<br>
So couldn't you create an *.ico file using .NET's resource manipulation namespaces?<br>
<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/e823c479868c4cb59c669dea012f0eda#e823c479868c4cb59c669dea012f0eda</link>
		<pubDate>Sun, 06 Nov 2005 19:23:53 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/e823c479868c4cb59c669dea012f0eda#e823c479868c4cb59c669dea012f0eda</guid>
		<dc:creator>W3bbo</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/W3bbo/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p>What are the .NET's resource manipulation namespaces?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/3bc9aa59668149d290fa9dea012f0f02#3bc9aa59668149d290fa9dea012f0f02</link>
		<pubDate>Sun, 06 Nov 2005 19:32:46 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/3bc9aa59668149d290fa9dea012f0f02#3bc9aa59668149d290fa9dea012f0f02</guid>
		<dc:creator>yyy</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/yyy/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p><blockquote>
<div>yyy wrote:</div>
<div>What are the .NET's resource manipulation namespaces?</div>
</blockquote>
<br>
<br>
System.Resources<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/e0e475bdde464f2b83d39dea012f0f2b#e0e475bdde464f2b83d39dea012f0f2b</link>
		<pubDate>Sun, 06 Nov 2005 19:36:11 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/e0e475bdde464f2b83d39dea012f0f2b#e0e475bdde464f2b83d39dea012f0f2b</guid>
		<dc:creator>W3bbo</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/W3bbo/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p>Thanks but I don't think I know how to use it in order to create the icon. An icon file's layout is quite complicated, as explained in this article:
<a href="http://www.codeproject.com/dotnet/MultiIcon.asp">http://www.codeproject.com/dotnet/MultiIcon.asp</a>&nbsp;. I think that if you need to convert a bitmap to an icon you'll first have to get a lot of information from that bitmap and that's the hard part.
 But maybe there's something I don't know about.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/c0b0c6e0c3df49e6b7bc9dea012f0f54#c0b0c6e0c3df49e6b7bc9dea012f0f54</link>
		<pubDate>Sun, 06 Nov 2005 20:39:47 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/c0b0c6e0c3df49e6b7bc9dea012f0f54#c0b0c6e0c3df49e6b7bc9dea012f0f54</guid>
		<dc:creator>yyy</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/yyy/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p>If you are willing to put one per file, you can just save it as a bitmap with the ICO extension.</p>
<p>Just make sure it is 16x16, 32x32, or&nbsp;64x64 if you want to work in most places.</p>
<p>Jorgie</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/673ed28ba1404aac93a29dea012f0f7d#673ed28ba1404aac93a29dea012f0f7d</link>
		<pubDate>Mon, 07 Nov 2005 02:42:33 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/673ed28ba1404aac93a29dea012f0f7d#673ed28ba1404aac93a29dea012f0f7d</guid>
		<dc:creator>Jorgie</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Jorgie/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p>Jorgie, by just changing the&nbsp;file extension, Windows Explorer seems to recognize it. But when it is used as a Windows Form icon, VS2005 throws an error, &quot;Argument 'picture' must be a picture that can be used as a Icon&quot;.<br>
<br>
After some reading, it appears that to correctly do it, I have to manupulate Bitmap headers and Icon headers / structs&nbsp;myself based on Windows API documentation; and there will be quite some coding. That is rather odd to me since it is a known problem;&nbsp;nonetheless
 .NET 2.0 chooses not to address it.<br>
<br>
Thanks guys for the replies. I will attemp to do some coding and it is surely going to be an interesting experience. <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif' alt='Wink' /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/add2281c7c6540dd97df9dea012f0fa7#add2281c7c6540dd97df9dea012f0fa7</link>
		<pubDate>Mon, 07 Nov 2005 05:51:52 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/add2281c7c6540dd97df9dea012f0fa7#add2281c7c6540dd97df9dea012f0fa7</guid>
		<dc:creator>Mar7in</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Mar7in/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p>Great - don't forget to tell us if you find out how to do it right. I'm also interested in this. BTW, maybe this can help you:
<a href="http://www.codeproject.com/dotnet/safeicon.asp">http://www.codeproject.com/dotnet/safeicon.asp</a>&nbsp;-&nbsp;it&nbsp;shows a code that can convert an Image object to an icon but it&nbsp;doesn't work with all sorts&nbsp;of icons.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/21e601810b7a4b899a499dea012f0fd0#21e601810b7a4b899a499dea012f0fd0</link>
		<pubDate>Mon, 07 Nov 2005 13:05:45 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/21e601810b7a4b899a499dea012f0fd0#21e601810b7a4b899a499dea012f0fd0</guid>
		<dc:creator>yyy</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/yyy/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">yyy said:</div><div class="quoteText">Great - don't forget to tell us if you find out how to do it right. I'm also interested in this. BTW, maybe this can help you:
<a href="http://www.codeproject.com/dotnet/safeicon.asp">http://www.codeproject.com/dotnet/safeicon.asp</a>&nbsp;-&nbsp;it&nbsp;shows a code that can convert an Image object to an icon but it&nbsp;doesn't work with all sorts&nbsp;of icons.</div></blockquote>has this been fixed in .NET 3.5 (maybe
 WPF)?<br>
<br>
i tried the freeimage lib, the sample for .NET didn't even compile.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/ad6e145862a9491c8a369dea012f1013#ad6e145862a9491c8a369dea012f1013</link>
		<pubDate>Mon, 28 Jul 2008 03:28:31 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/ad6e145862a9491c8a369dea012f1013#ad6e145862a9491c8a369dea012f1013</guid>
		<dc:creator>googlexp</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/googlexp/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">googlexp said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">yyy said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
has this been fixed in .NET 3.5 (maybe WPF)?<br>
<br>
i tried the freeimage lib, the sample for .NET didn't even compile.</div></blockquote>the .NET framework's class libraries have only been extended in .NET 3.0 and 3.5, all the core assemblies remain the same. So no.<br>
<br>
Re: Jorgie: that wouldn't work because an ICO is application/x-icon, Explorer is just more tolerant and loads up the Win32 bitmap reader despite the file extension, a proper icon reader would choke on it.<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/57695b9127a748a4b06a9dea012f103c#57695b9127a748a4b06a9dea012f103c</link>
		<pubDate>Mon, 28 Jul 2008 07:30:23 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/57695b9127a748a4b06a9dea012f103c#57695b9127a748a4b06a9dea012f103c</guid>
		<dc:creator>W3bbo</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/W3bbo/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - C# 2.0 convert Bitmap to Icon problem</title>
		<description><![CDATA[<p>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; System.IO.Stream outputStream;<br>
<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Icon tIco;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Bitmap tBmp = new Bitmap(pictureBox1.Image);<br>
<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;outputStream = System.IO.File.Create(@textBox2.Text);<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;tIco = Icon.FromHandle(tBmp.GetHicon());<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;tIco.Save(outputStream);<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;outputStream.Close();<br>
<br>
----<br>
<br>
&nbsp;&nbsp; The only problem I have with the code it the apparent loss of colors.&nbsp; Though the end result does show up in properties as 32bit.<br>
<br>
&nbsp;&nbsp; This will allow you to use the icon as an icon on your forms.<br>
<br>
-Chazm<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/ddf141243a4a4301b2839dea012f1081#ddf141243a4a4301b2839dea012f1081</link>
		<pubDate>Fri, 24 Oct 2008 20:25:00 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/130238-C-20-convert-Bitmap-to-Icon-problem/ddf141243a4a4301b2839dea012f1081#ddf141243a4a4301b2839dea012f1081</guid>
		<dc:creator>ChazmCoder</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/ChazmCoder/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>