473,761 Members | 8,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Save BitMap as Icon

I give up...I have tried all combinations that I can think of and I can't get
a bitmap converted to an icon and save it in a filestream or stream;

Any help would be appreciated.
--
Dennis in Houston
Nov 21 '05 #1
5 2887
Hi,

Dim bm As New Bitmap("C:\Came ra.bmp")

Dim ico As Icon = Icon.FromHandle (bm.GetHicon)

Dim fs As New System.IO.FileS tream("C:\Camer a.ico", IO.FileMode.Cre ateNew)

ico.Save(fs)

fs.Close()

Ken

-------------------------------

"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:BD******** *************** ***********@mic rosoft.com...
I give up...I have tried all combinations that I can think of and I can't
get
a bitmap converted to an icon and save it in a filestream or stream;

Any help would be appreciated.
--
Dennis in Houston
Nov 21 '05 #2
"Dennis" <De****@discuss ions.microsoft. com> schrieb:
I give up...I have tried all combinations that I can think
of and I can't get a bitmap converted to an icon and
save it in a filestream or stream;


<URL:http://vbaccelerator.c om/article.asp?id= 4567>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3
Ken,

Looks great can this be seen as your code, because I have put it in a
snippet with your name.

Cor
Nov 21 '05 #4
Thanks a lot..I've been working on this for 2 days now. I wonder why this
doesn't work?

Dim fmt As ImageFormat
fmt = ImageFormat.Ico n
im2.Save("c:\ic on1.ico", fmt)

It give an error that value cannot be null, Parameter Encoder.

"Ken Tucker [MVP]" wrote:
Hi,

Dim bm As New Bitmap("C:\Came ra.bmp")

Dim ico As Icon = Icon.FromHandle (bm.GetHicon)

Dim fs As New System.IO.FileS tream("C:\Camer a.ico", IO.FileMode.Cre ateNew)

ico.Save(fs)

fs.Close()

Ken

-------------------------------

"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:BD******** *************** ***********@mic rosoft.com...
I give up...I have tried all combinations that I can think of and I can't
get
a bitmap converted to an icon and save it in a filestream or stream;

Any help would be appreciated.
--
Dennis in Houston

Nov 21 '05 #5
Hi,

Dim bm As New Bitmap("c:\came ra.bmp")

bm.Save("C:\Cam era.ico", Imaging.ImageFo rmat.Icon)

Ken

---------------------------------------

"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:89******** *************** ***********@mic rosoft.com...
Thanks a lot..I've been working on this for 2 days now. I wonder why this
doesn't work?

Dim fmt As ImageFormat
fmt = ImageFormat.Ico n
im2.Save("c:\ic on1.ico", fmt)

It give an error that value cannot be null, Parameter Encoder.

"Ken Tucker [MVP]" wrote:
Hi,

Dim bm As New Bitmap("C:\Came ra.bmp")

Dim ico As Icon = Icon.FromHandle (bm.GetHicon)

Dim fs As New System.IO.FileS tream("C:\Camer a.ico", IO.FileMode.Cre ateNew)

ico.Save(fs)

fs.Close()

Ken

-------------------------------

"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:BD******** *************** ***********@mic rosoft.com...
I give up...I have tried all combinations that I can think of and I can't
get
a bitmap converted to an icon and save it in a filestream or stream;

Any help would be appreciated.
--
Dennis in Houston

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
7478
by: BC | last post by:
Hello, We are creating an Office add-in. We are able to display the add-in successfully. However, we followed a sample program, and it displays a FaceID = 1044 (which is not the bitmap of the button we want to display). We want to display our own custom bitmap. How do we display our own custom bitmap instead of the bitmap associated with FaceID = 1044?
2
2334
by: Carl Gilbert | last post by:
Hi I have to following code which sets up a new bitmap. 'set up a transparent 16x16 bitmap Dim bm As New Bitmap(16, 16) Dim g As Graphics = Graphics.FromImage(bm) g.Clear(System.Drawing.Color.Transparent) 'draw a rectangle on the transparent bitmap
2
429
by: Dennis | last post by:
I have created a bitmap and set the transparency color to black; mybitmap.MakeTransparent(Color.Black) myicon = Icon.FromHandle(bm.GetHicon) This creates the icon ok but the background color black is not transparent. How do I create an Icon from this bitmap that has also the color black transparent?
2
3181
by: jaumef_2000 | last post by:
Hello, I'm developing a Standard Windows App and I need to deal with Icons. I've read lots of posts about them and I'm missing something. I put this code in a button click in a new brand new solution: Bitmap bmp = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsApplication1.Bitmap1.bmp")); Icon ic = Icon.FromHandle(bmp.GetHicon()); Icon ic2 = new
2
4567
by: Dennis | last post by:
I have about 50 images in my application as "embedded resources". They are Icon size (16x16 and 24x24 and 32x32). I can use either the bitmap version or convert them to Icons. Either way seems to work ok (I make the color of the upper left pixel in the bitmap's the transparent color). I noted that the Icons take up 25k and the bitmaps only 1k). Which would be the recommended way to go, i.e., icons or bitmaps in my imagelist? Any...
3
16744
by: SveinErik | last post by:
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";
4
3582
by: Frank | last post by:
Private Sub SaveBitmap(ByVal fileName As String, ByVal p As System.Drawing.Bitmap) ...snip p.Save(fileName, Imaging.ImageFormat.Icon) Does not produce an icon formatted file. At least if I try to open it with icon reading programs it does not open.
2
2894
by: Smokey Grindel | last post by:
when I do this code Dim HIcon As IntPtr = bmp.GetHicon to convert a Bitmap which is just a 16x16 image I pulled from a resource originally as an icon (16x16x32bit) then converted into a bitmap to draw on it's surface then wanted to convert back to an icon... but when I do the other two commands Using bmp As Bitmap = My.Resources.bell.ToBitmap Using g As Graphics = Graphics.FromImage(bmp) end using end using
0
1427
Computer Guru
by: Computer Guru | last post by:
On Error Resume Next Dim SaveFileDialog As New SaveFileDialog SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments SaveFileDialog.Filter = "Icon (*.ico)|*.ico" If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then Dim sFilename As String = SaveFileDialog.FileName
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
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...
1
9902
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
9765
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
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
7327
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
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2738
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.