How would i convert an Bitmap to an Icon. I cant fiure i out.

Recommended Answers

All 13 Replies

You need to use the System.Drawing namespace. Something like this should get you started:

Bitmap b = new Bitmap(@"C:\WINDOWS\Blue Lace 16.bmp");
IntPtr hIcon = b.GetHicon();
Icon i = Icon.FromHandle(hIcon);

You need to use the System.Drawing namespace. Something like this should get you started:

Bitmap b = new Bitmap(@"C:\WINDOWS\Blue Lace 16.bmp");
IntPtr hIcon = b.GetHicon();
Icon i = Icon.FromHandle(hIcon);

spo this turns the blue lace bmp into an icon...if so where does it go

Wherever you want it to go... it's only an icon object. If you want to save it to disk, then you would add code to do that (use the "Save" method of the Icon object). If you want to set the icon as the icon of your form, you would use "this.icon = i;".

Wherever you want it to go... it's only an icon object. If you want to save it to disk, then you would add code to do that (use the "Save" method of the Icon object). If you want to set the icon as the icon of your form, you would use "this.icon = i;".

Sorry, but i dont no what u mean when u save i.save.... or somthing like that.

TIA

Please spell out all your words; otherwise we can never communicate clearly.

I've shown you how to convert a bitmap into an icon. I've shown you that you can save the icon to disk, if you like, using the .Save method of the System.Drawing.Icon object. I've also shown you how to set the Form's icon to your icon object using the "this.Icon" property.

What else do you need to know?

Please spell out all your words; otherwise we can never communicate clearly.

I've shown you how to convert a bitmap into an icon. I've shown you that you can save the icon to disk, if you like, using the .Save method of the System.Drawing.Icon object. I've also shown you how to set the Form's icon to your icon object using the "this.Icon" property.

What else do you need to know?

Hi, i would like to know how to save to disk.

this is what i have

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
 
        }

        private void button1_Click(object sender, EventArgs e)
        {

            Bitmap b = new Bitmap(@"C:\WINDOWS\Blue Lace 16.bmp");
            IntPtr hIcon = b.GetHicon();
            Icon i = Icon.FromHandle(hIcon);
            i.Save(@"c:\");
            
         
        }


    }
}

it doesnt work i just need a snippet on how do it it .

Thanks

i dont know about in 2005, but in vs.net 2003 you can create a new icon file, then import the image you want, and lets you crop it and edit it or whatever, then you can save it

i dont know about in 2005, but in vs.net 2003 you can create a new icon file, then import the image you want, and lets you crop it and edit it or whatever, then you can save it

i no ino but i am really new and i dont even no where to start. how do i make this new icon. how do i save it. please clear it up. im so confused

Did you look at the documentation for the "Save" method? I'm not trying to be mean, but if you want to be a succesful programmer, you'll have to learn to read documentation, plus (a personal pet peeve of mine), type and punctuate clearly. You can't refuse to read documentation, and be sloppy in your questions, spelling, and punctuation, and find many people willing to stick with you through a problem.

According to the MSDN Documentation, the Save method of the Icon object takes a Stream as its argument. So, you'll need to create a Stream Object.

If you don't know what a Stream Object is, then you'll have to read up on it. There isn't a quick and dirty solution I can give you. So far you've got a bitmap, and extracted an icon object from it. You know it has a "save" method, and you know it saves it to a "stream" object. You have links to the documentation for the method and the Stream object.

Take it from there!

Did you look at the documentation for the "Save" method? I'm not trying to be mean, but if you want to be a succesful programmer, you'll have to learn to read documentation, plus (a personal pet peeve of mine), type and punctuate clearly. You can't refuse to read documentation, and be sloppy in your questions, spelling, and punctuation, and find many people willing to stick with you through a problem.

According to theMSDN Documentation, the Save method of the Icon object takes a Stream as its argument. So, you'll need to create a Stream Object.

If you don't know what a Stream Object is, then you'll have to read up on it. There isn't a quick and dirty solution I can give you. So far you've got a bitmap, and extracted an icon object from it. You know it has a "save" method, and you know it saves it to a "stream" object. You have links to the documentation for the method and the Stream object.

Take it from there!

Will do, thank you for your time.

-T

i dont know about in 2005, but in vs.net 2003 you can create a new icon file, then import the image you want, and lets you crop it and edit it or whatever, then you can save it

plazmo how do i do that

plazmo how do i do that

go to File>New>File>General>Icon File

this is how you do it in vs.net i dont know if its like this in express

go to File>New>File>General>Icon File

this is how you do it in vs.net i dont know if its like this in express

No, cant do that here...:( o well i will continue my research :mrgreen:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.