Converting BitMap to Icon

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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?
 
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.
 
Back
Top