473,604 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Clic k(object sender, EventArgs e)
{
string source = @"d:\image.bmp" ;
string target = @"d:\image.ico" ;

BmpToIcon(sourc e, target);
}

public static void BmpToIcon(strin g sourcePath, string
targetPath)
{

// Retrieve the bitmap from the file.
Bitmap bmp = (Bitmap)Image.F romFile(sourceP ath);
// 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(targ etPath, 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 16724
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.comw rote in message
news:11******** *************@a 34g2000cwb.goog legroups.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
2870
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 displayed at the left of the name of the page. How do I do this? I am using Frontpage 2002, but know how to edit HTML manually. Thanks,
0
1299
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 resulting in an awful picture. Does anyone know how to solve this problem? I tried using
1
2105
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 resource, I want to draw the 16x16 one on the screen, how would I do this? the only icon i get back when making a icon object out of it is 32x32.. but i need the smaller one, thanks!
3
8046
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 transparent) background. Any ideas why?
3
3024
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 this Dim ico As Drawing.Icon = New Drawing.Icon(GetType(bdbGeneral).Assembly.GetManifestResourceStream("bdb.plugin.ico")) Dim icoMyIcon As Drawing.Icon = New Drawing.Icon(ico, SystemInformation.SmallIconSize)
4
3836
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 size: sometimes it resizes the 48x48 image to 16x16 instead of taking the 16x16 image. Is there a way to specify which image of the icon has to be used? Thansk a lot in advance,
3
398
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 application forms. However, this only occures on one machine running windows 2003 server. Anyone expierance such problem? Any suggestions on how I should approach the problem. TIA, Rich
0
1191
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. Problem is that the icon extracted is large (32x32) and I want to display small (16x16). The icons look terrible as they are being resized by Windows etc.
6
3917
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 PictureBox control. I made some searchs and discovered that the Icon.ExtractAssociatedIcon() function can do what I want, but only for the smallest icon size, ie 16x16 here... I tried Assembly.GetManifestResourceStream() also but I didn't
0
7997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8419
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8409
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8065
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6739
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5882
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3955
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.