<?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>dotnet thoughts &#187; Convert Image to Icon</title>
	<atom:link href="http://www.dotnetthoughts.net/tag/convert-image-to-icon/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dotnetthoughts.net</link>
	<description>a dotnet developer&#039;s technical blog</description>
	<lastBuildDate>Wed, 08 Feb 2012 03:18:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.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 &#8230; <a href="http://www.dotnetthoughts.net/2009/09/30/convert-image-to-icon-using-c/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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; title: ; notranslate">
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>
<div class="betterrelated"><p><strong>Related content:</strong></p>
<ol><li> <a href="http://www.dotnetthoughts.net/2009/10/07/how-to-store-and-retrieve-files-from-sql-server-database/" title="Permanent link to How to Store and Retrieve files from SQL Server Database">How to Store and Retrieve files from SQL Server Database</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2009/09/22/adding-and-reading-files-from-sql-server-2008-filestream/" title="Permanent link to Adding and Reading files from SQL Server 2008 Filestream">Adding and Reading files from SQL Server 2008 Filestream</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2009/07/28/uploading-files-using-webservice/" title="Permanent link to Uploading Files using Webservice">Uploading Files using Webservice</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2009/07/06/filestream-in-sql-server-2008/" title="Permanent link to FILESTREAM in SQL Server 2008">FILESTREAM in SQL Server 2008</a>  </li>
<li> <a href="http://www.dotnetthoughts.net/2009/07/10/consuming-a-c-dll-in-c/" title="Permanent link to Consuming a C++ DLL in C#">Consuming a C++ DLL in C#</a>  </li>
</ol></div>]]></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>

