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

S

SveinErik

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
targetPath)
{

// 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.
ico.Save(st);

// Close the file to write the stream to the disk.
wr.Close();
}
 
S

SveinErik

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..?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top