Forum Moderators: open

Message Too Old, No Replies

Converting Bitmaps to Icons

         

badger111

7:33 pm on Jan 31, 2006 (gmt 0)

10+ Year Member



Can anybody give me an example of converting bitmaps to icons using vb.net - and/or point me to a good resource.

many many thanks

lee

Dijkgraaf

7:47 pm on Feb 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What exactly do you mean by Icons?
Like the favicon.ico format, or something else?

badger111

9:19 pm on Feb 1, 2006 (gmt 0)

10+ Year Member



using the system.drawing .net library to convert .bmp files to .ico format

Dijkgraaf

9:33 pm on Feb 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you done a search with your favourite search engine for system.drawing .net .bmp .ico?
I'm finding various pages discussing it and even some examples.

wildbest

10:02 pm on Feb 1, 2006 (gmt 0)

badger111

12:55 am on Feb 2, 2006 (gmt 0)

10+ Year Member



I've have a trawl throught a large chunk of the info in webland regarding using system.drawing library to convert bitmaps to icons (or bitmaps to wmf) and it seems that you cant! not with this library anyway MS KB 316563. knackers! anybody got any other ideas - i just need something 'quick and dirty'.

regards
lee (with a little less hair)

Dijkgraaf

1:36 am on Feb 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well bitmaps to wmf I can understand being a problem, as a bmp is a raster format and a wmf is a vector format, however going from bmp to ico should not be a problem as they are both raster formats.

I'll sticky you a URL that might do the trick, they have it as a web service which is not quite what you are after, but the rest of the code might do the trick.

badger111

11:46 am on Feb 2, 2006 (gmt 0)

10+ Year Member



hey Dijkgraaf

i saw that piece of code on my trawl. the problem is that using the Imaging.Save method of the System.Drawing library to convert a .bmp to .ico creates a .png file!

still looking...

cheers
lee

duckhunter

5:21 am on Feb 7, 2006 (gmt 0)

10+ Year Member



Thanks for posing the question. I've been wanting to update my favicon.ico, just didn't have the software loaded to do the .ico. Didn't think about .NET's abilities. What will it be able to do next?

Imports System.IO

Dim bmp As Bitmap = CType(Bitmap.FromFile("C:\inetpub\wwwroot\TestBed\file.bmp"), Bitmap)
Dim ico As Icon = Icon.FromHandle(bmp.GetHicon())
Dim file As FileStream = New FileStream("C:\inetpub\wwwroot\TestBed\file.ico", FileMode.OpenOrCreate)
ico.Save(file)
file.Close()
ico.Dispose()