473,412 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

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

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();
}

Feb 2 '07 #1
3 16691
Please, can someone help me?

Feb 2 '07 #2
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" <sv****************@gmail.comwrote in message
news:11*********************@a34g2000cwb.googlegro ups.com...
Please, can someone help me?

Feb 3 '07 #3
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ed Isenberg | last post by:
I notice that a lot of Web pages have an icon that is displayed preceding the URL in the place in the browser where the URL is displayed. When I bookmark or add this to Favorites the icon is also...
0
by: Paul Rohorzka | last post by:
Hi! A2k I set a form's icon to a multiresolution (16x16 and 32x32) icon file. When I am switching tasks, access obviously uses the 16x16 icon and blows it up to the needed 32x32 size...
1
by: Brian Henry | last post by:
I have an icon in my app as an embeded resource.. i am accessing it through the assemblies getmainfestresourcestream method of the assembly. The icon has a 32x32 and a 16x16 icon in the same icon...
3
by: Jo Franklin | last post by:
I am using icon.save to save icon files I've extracted using ExtractIconEx. when I save the large icon everything is fine, but when I save the small icon it looks distorted, and has a black (not...
3
by: Brian Henry | last post by:
I have icons which contain 16x16, 24x24, and 32x32 icons in the single file and it is embedded as a resource... I need to get a 16x16 icon only out of it, how would i go about doing that? ive tried...
4
by: Pieter | last post by:
Hi, In my VB.NET 2005 application I want to reuse several icons in different sizes. My icons contains images of 16x16, 24x24, 32x32 and 48x48. The problem is: I doesn't always use the right...
3
by: koredump | last post by:
Hi, I have an application that's being deployed using ClickOnce. Once deployed and installed on client machine, the form icon that I have added using the designer won't show up in any of the...
0
by: Mark | last post by:
Hi I tried to find a solution to this a while back and more surfing today has yielded nothing usefull. I am using "extractAssociatedIcon" to get icons for a listview containing files etc....
6
by: Laurent Navarro | last post by:
Hello, I have an EXE (.NET assembly) file with an icon which has 8 formats (128x128, 96x961, ..., 24x24 and 16x16). I would like the extract the 128x128 sized icon only to display it on a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.