<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dot Net Thoughts &#187; Icon</title>
	<atom:link href="http://www.dotnetthoughts.net/tag/icon/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dotnetthoughts.net</link>
	<description>thoughts about .Net, WPF, Sharepoint, Javascript and more.</description>
	<lastBuildDate>Wed, 28 Jul 2010 09:59:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Convert Image to Icon using C#</title>
		<link>http://www.dotnetthoughts.net/2009/09/30/convert-image-to-icon-using-c/</link>
		<comments>http://www.dotnetthoughts.net/2009/09/30/convert-image-to-icon-using-c/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 11:54:53 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Win 32 API]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[Convert Image to Icon]]></category>
		<category><![CDATA[Drawing]]></category>
		<category><![CDATA[Icon]]></category>
		<category><![CDATA[Image to Icon]]></category>

		<guid isPermaLink="false">http://anuraj.wordpress.com/?p=404</guid>
		<description><![CDATA[Sometimes we will get nice Images from Web as Icons. But we can&#8217;t use these Images as application icons in .Net, because the .Net supports *.ico(Icon) format only. This code will convert an Image to Icon using C#. It is written .Net Framework 3.5, but it should work in .Net 2.0. It supports Images upto [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes we will get nice Images from Web as Icons. But we can&#8217;t use these Images as application icons in .Net, because the .Net supports *.ico(Icon) format only. This code will convert an Image to Icon using C#. It is written .Net Framework 3.5, but it should work in .Net 2.0. It supports Images upto size 128&#215;128. And supports various image formats(*.jpg,*.gif, *.png. *.bmp).</p>
<pre class="brush: csharp;">
using System;
using System.Drawing;
using System.IO;

string fileName, newFileName;
fileName = &quot;C:\Sample.jpg&quot;;
newFileName = Path.ChangeExtension(fileName, &quot;.ico&quot;);
using (Bitmap bitmap = Image.FromFile(fileName, true) as Bitmap)
{
    using (Icon icon = Icon.FromHandle(bitmap.GetHicon()))
    {
        using (Stream imageFile = File.Create(newFileName))
        {
            icon.Save(imageFile);
            Console.WriteLine(&quot;Converted - {0}&quot;, newFileName);
        }
    }
}
</pre>
<p>Code it pretty self explanatory. Let me know if you have faced any issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2009/09/30/convert-image-to-icon-using-c/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
