Bitmap to Icon

G

Guest

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?
 
K

Ken Tucker [MVP]

Hi,

Dim bm As New Bitmap(16, 16)

Dim g As Graphics = Graphics.FromImage(bm)

g.Clear(Color.Black)

g.DrawEllipse(Pens.White, 0, 0, 16, 16)

bm.MakeTransparent(Color.Black)

Dim ico As Drawing.Icon

ico = Drawing.Icon.FromHandle(bm.GetHicon)

Me.Icon = ico



Ken

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

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?
 
G

Guest

What I'm doing is reading an .ico file then converting it to a bitmap which I
then resize. I make the background color transparent then convert it back to
an icon file. The resulting bitmap after resizing shows ok with the
background color black transparent but the resulting icon doesn't have the
background color black transparent.
 

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