Connecting Tech Pros Worldwide Forums | Help | Site Map

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

SveinErik
Guest
 
Posts: n/a
#1: Feb 2 '07
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();
}


SveinErik
Guest
 
Posts: n/a
#2: Feb 2 '07

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


Please, can someone help me?

Michael Phillips, Jr.
Guest
 
Posts: n/a
#3: Feb 3 '07

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


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:
http://www.codeguru.com/csharp/.net/...nt.php/c12787/


"SveinErik" <svein.erik.storkas@gmail.comwrote in message
news:1170450687.889035.86170@a34g2000cwb.googlegro ups.com...
Quote:
Please, can someone help me?
>

SveinErik
Guest
 
Posts: n/a
#4: Feb 3 '07

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


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

Closed Thread