Tech Off Post

Single Post Permalink

View Thread: C# 2.0 convert Bitmap to Icon problem
  • User profile image

                System.IO.Stream outputStream;

                Icon tIco;
                Bitmap tBmp = new Bitmap(pictureBox1.Image);

                outputStream = System.IO.File.Create(@textBox2.Text);
                tIco = Icon.FromHandle(tBmp.GetHicon());


       The only problem I have with the code it the apparent loss of colors.  Though the end result does show up in properties as 32bit.

       This will allow you to use the icon as an icon on your forms.