Converting BitMap to Icon

G

Guest

I have a bitmap and make the color transparent;

mybitmap.MakeTransparent(Color.Black)

When I save it as a Icon, the black color is not transparent. However, if I
save it as a bitmap then display it using windows explorer, the black color
is in fact transparent. Could it be that the bitmap is not an alpha bitmap
that causes the icon to not have the black color transparent?
 
K

Ken Tucker [MVP]

Hi,

Even when I save a icon with its back color as color.transparent it
shows up with a black background in windows explorer.

Dim bm As New Bitmap(16, 16)

Dim ico As Icon

Dim g As Graphics = Graphics.FromImage(bm)

g.Clear(Color.Transparent)

g.FillEllipse(Brushes.Red, 0, 0, 16, 16)

g.Dispose()

Dim ptr As IntPtr = bm.GetHicon

ico = Icon.FromHandle(ptr)

Me.Icon = ico

Dim fs As New System.IO.FileStream("Test.ico", IO.FileMode.Create)

ico.Save(fs)

fs.Close()



Ken

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

I have a bitmap and make the color transparent;

mybitmap.MakeTransparent(Color.Black)

When I save it as a Icon, the black color is not transparent. However, if I
save it as a bitmap then display it using windows explorer, the black color
is in fact transparent. Could it be that the bitmap is not an alpha bitmap
that causes the icon to not have the black color transparent?
 
G

Guest

This creates an icon with a red circle and black background. I want to take
an existing bitmap and convert it into an icon with a transparent backcolor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top