﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum / General .NET Discussion / .NET Forums  / How to convert a Bitmap to Icon at code level? / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>forum@strataframe.net</webMaster><lastBuildDate>Fri, 21 Nov 2008 16:08:17 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>...&lt;/P&gt;&lt;P&gt;:crying:</description><pubDate>Tue, 17 Jul 2007 15:07:29 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>Nah, the beta only lasted for 3 weeks... they took it offline back on June 10th... As for the game itself, it will be out on Sept. 25th (at least here in the states).  Not sure about the distribution down in Brazil, but if you have an Xbox 360 with the right region coding, you can play games from the US.</description><pubDate>Tue, 17 Jul 2007 14:03:32 GMT</pubDate><dc:creator>Ben Chase</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>[quote]Oh, yeah, I racked up about 140 games on the 3 weeks that it was running... only played enough games to make Lieutenant, but I did have a kill/death ratio of about 2.3... something like 2300 kills and 900 deaths.  They took down the online stats so I don't remember what they were exactly. [/quote]&lt;P&gt;:w00t:  totally speechless&lt;P&gt;Is it possible to get it and play it over here?</description><pubDate>Tue, 17 Jul 2007 13:26:30 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>[quote]Have you played the Halo3 beta?[/quote]&lt;/P&gt;&lt;P&gt;Oh, yeah, I racked up about 140 games on the 3 weeks that it was running... only played enough games to make Lieutenant, but I did have a kill/death ratio of about 2.3... something like 2300 kills and 900 deaths.  They took down the online stats so I don't remember what they were exactly. </description><pubDate>Tue, 17 Jul 2007 13:20:22 GMT</pubDate><dc:creator>Ben Chase</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>Hey Ben.&lt;/P&gt;&lt;P&gt;Have you played the Halo3 beta?</description><pubDate>Tue, 17 Jul 2007 09:23:08 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>[quote]Check out the trailers for Crysis &lt;A href="http://www.crysis-online.com/"&gt;http://www.crysis-online.com/&lt;/A&gt; [/quote]&lt;/P&gt;&lt;P&gt;Oh, yeah, that is going to be a beautiful game.  The guys over at Kotaku.com said they got a pretty good hands on at E3 last week and said that no only are the graphics and engine beautiful, but the gameplay is really going to shine as well.  For right now, though, I'd have to honestly say that I think I'm more interested in Halo 3 (duh...) and Mass Effect (masseffect.bioware.com) which is going to be just phenominal.</description><pubDate>Mon, 16 Jul 2007 15:52:57 GMT</pubDate><dc:creator>Ben Chase</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>Thanks Ben !&lt;/P&gt;&lt;P&gt;I wanted to make sure there was no gotcha that I didn't know about! :) &lt;/P&gt;&lt;P&gt;Check out the trailers for Crysis &lt;A href="http://www.crysis-online.com/"&gt;http://www.crysis-online.com/&lt;/A&gt;</description><pubDate>Mon, 16 Jul 2007 09:51:26 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>[quote]GetHIcon()[/quote]&lt;/P&gt;&lt;P&gt;Nice, one Paul... I always forget about that one.&lt;/P&gt;&lt;P&gt;[quote]Why do you prefer embedding vs adding as a resource?[/quote]&lt;/P&gt;&lt;P&gt;Well, they're essentiall the same thing... when you add it as a resource, it gets added to the .resx file, which itself is embedded.  Pretty much the same difference.&lt;/P&gt;&lt;P&gt;But the main reason I mentioned embedding is that for some reason, I was thinking that when you added icons to the project resources (or any other resx file), they were added as images.  However, I now see that there are separate categories for Images and Icons... so, I stand corrected :)&lt;/P&gt;&lt;P&gt;So, for Ben H, it probably would be easier to add the icon as an ICO file to the Icons of your resources and just retrieve it through the default resource manager since it will create the strong-typed property for it.</description><pubDate>Mon, 16 Jul 2007 08:59:29 GMT</pubDate><dc:creator>Ben Chase</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>[quote][b]Paul Chase (07/13/2007)[/b][hr]Ben H,&lt;br&gt;&lt;br&gt;Here is how to accomplish what you originally asked in VB,For C# you would probably just have to change the casting.&lt;br&gt;&lt;br&gt;&lt;FONT size=2&gt;NotifyIcon1.Icon = System.Drawing.Icon.FromHandle(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CType&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.ImageList1.Images(0), Drawing.Bitmap).GetHicon)&lt;/FONT&gt;&lt;br&gt;&lt;br&gt;&lt;FONT size=2&gt;Ben C,&lt;br&gt;&lt;br&gt;Why do you prefer embedding vs adding as a resource?&lt;br&gt;&lt;br&gt;Paul&lt;/FONT&gt;[/quote]&lt;br&gt;&lt;br&gt;Paul, thank you very much for your contribution. I went ahead and did it in C# and works great.&lt;br&gt;If you don't mind, I'll post your solution along side Ben's in the sample area.&lt;br&gt;&lt;br&gt;Once again, Thanks!</description><pubDate>Fri, 13 Jul 2007 15:24:22 GMT</pubDate><dc:creator>Ben Hayat</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>Ben H,&lt;/P&gt;&lt;P&gt;Here is how to accomplish what you originally asked in VB, For C# you would probably just have to change the casting.&lt;/P&gt;&lt;P&gt; &lt;FONT size=2&gt;NotifyIcon1.Icon = System.Drawing.Icon.FromHandle(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CType&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.ImageList1.Images(0), Drawing.Bitmap).GetHicon)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Ben C ,&lt;/P&gt;&lt;P&gt;Why do you prefer embedding vs adding as a resource?&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Fri, 13 Jul 2007 13:33:55 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>Thank you very much Sir;&lt;br&gt;&lt;br&gt;[quote]Hehe, no not really... the Image and Icon are completely different... mainly because Icon does not inherit from Image (the file formats are completely different since an Icon can have several different sizes within the file). [/quote]I sadly learned that very quickly (not that I was happy about)&lt;br&gt;&lt;br&gt;[quote]So, I would recommend that you add the icons to your project (not as resources, just add them to the project with the "Add Exisiting Item" option) and change their compile option to Embedded Resource (in the properties for the file). [/quote]This the way I thought about doing, but didn't know I can "Embed" a resource. I need to look at that.&lt;br&gt;&lt;br&gt;[quote]C# and VB do some different stuff for the name of the resource when it's compiled. [/quote]I remember clearly from the class you brought that point up, about the differences in VB and C# and also with the "With" clause!&lt;br&gt;&lt;br&gt;I'm going to approach it this way. Thanks again.&lt;br&gt;&lt;br&gt;p.s. Ben if you don't mind, I'm going to put your solution in the new section of samples as a new library of codes. If you don't like it, go ahead and delete it.</description><pubDate>Fri, 13 Jul 2007 09:44:03 GMT</pubDate><dc:creator>Ben Hayat</dc:creator></item><item><title>RE: How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>Hehe, no not really... the Image and Icon are completely different... mainly because Icon does not inherit from Image (the file formats are completely different since an Icon can have several different sizes within the file).  So, I would recommend that you add the icons to your project (not as resources, just add them to the project with the "Add Exisiting Item" option) and change their compile option to Embedded Resource (in the properties for the file).  Then, you can use the Icon constructor that accepts a stream to retrieve the embedded resources.  Kinda like this:&lt;/P&gt;&lt;P&gt;notifyIcon1.Icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("RootNamespace.Folders.FileName"));&lt;/P&gt;&lt;P&gt;C# and VB do some different stuff for the name of the resource when it's compiled.  C# uses the root namespace + the folder names separated by "." followed by the filename.  Whereas VB just the root namespace + the filename.  If you ever want to see what resources are available, you can use the Assembly.GetExecutingAssembly().GetManifestResourceNames(); method which will return the names of all of the resources.  Oh, and the names are case-sensitive. &lt;/P&gt;&lt;P&gt;But that's probably your best be for retrieving icons from the assembly at runtime.</description><pubDate>Fri, 13 Jul 2007 09:17:31 GMT</pubDate><dc:creator>Ben Chase</dc:creator></item><item><title>How to convert a Bitmap to Icon at code level?</title><link>http://forum.strataframe.net/Topic10237-14-1.aspx</link><description>Here is where I'm running to this issue.&lt;br&gt;&lt;br&gt;I have a "NotifyIcon" that at runtime, I need to change the icon. But I don't want to grab the icon from disk. So, I placed an "ImageList" and put my Icons in it.&lt;br&gt;&lt;br&gt;Now when I try to assign one of those images to NotifyIcon.Icon, the compiler complains that the Image from Imagelist is not an "Icon".&lt;br&gt;notifyIcon1.Icon = imageList1.Images[0];&lt;br&gt;&lt;br&gt;I've looked around and can't find a way to convert the image from Imagelist to Icon.&lt;br&gt;&lt;br&gt;Any pointers?&lt;br&gt;Thanks!</description><pubDate>Thu, 12 Jul 2007 10:17:14 GMT</pubDate><dc:creator>Ben Hayat</dc:creator></item></channel></rss>