By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,330 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,330 IT Pros & Developers. It's quick & easy.

Save bmp/jpg/ icon (16x16) - Problem..

P: n/a
Hi, I'm trying to find a method to save bmp, jpg and png files as ico
files, 16x16 size. I have managed to convert and save bmp files to
icon, but only in 32x32 size. I can't figure out how to save it in the
size: 16x16, and I hope someone could help me out a bit?

Code that saves from bmp to ico (32x32):

private void cmdConvert_Click(object sender, EventArgs e)
string source = @"d:\image.bmp";
string target = @"d:\image.ico";

BmpToIcon(source, target);

public static void BmpToIcon(string sourcePath, string

// Retrieve the bitmap from the file.
Bitmap bmp = (Bitmap)Image.FromFile(sourcePath);
// Convert the bitmap to an icon.
Icon ico = Icon.FromHandle(bmp.GetHicon());
// Create a file stream to save the icon stream.
Stream st = new FileStream(targetPath, FileMode.Create);

// Create a stream writer to physical write the data to
the disk.
BinaryWriter wr = new BinaryWriter(st);

// Write the binary icon data to the file stream.

// Close the file to write the stream to the disk.

Feb 2 '07 #1
Share this Question
Share on Google+
3 Replies

P: n/a
Please, can someone help me?

Feb 2 '07 #2

P: n/a
There is no easy way, as there are no exposed methods that allow you to
accomplish your goal.

I suggest that you use the library available here:
"SveinErik" <sv****************@gmail.comwrote in message
Please, can someone help me?

Feb 3 '07 #3

P: n/a
Thanks, I already tried that library, it looks great! But I'm a
newbie, and it looks like you can only load dll, exe files and so
on..not individual bmp's and jpg's..?

Feb 3 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.