Home All Groups Group Topic Archive Search About

Converting BitMap to Icon

Author
27 Jun 2005 1:54 AM
Dennis
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?

--
Dennis in Houston

Author
27 Jun 2005 7:57 AM
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

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

"Dennis" <Den***@discussions.microsoft.com> wrote in message
news:9247C07B-8759-4737-9760-E84C25851E62@microsoft.com...
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?

--
Dennis in Houston
Author
28 Jun 2005 10:37 PM
Dennis
Thanks I'll try it.
--
Dennis in Houston


Show quoteHide quote
"Ken Tucker [MVP]" wrote:

> 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
>
> -----------------------------
>
> "Dennis" <Den***@discussions.microsoft.com> wrote in message
> news:9247C07B-8759-4737-9760-E84C25851E62@microsoft.com...
> 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?
>
> --
> Dennis in Houston
>
>
>
Author
1 Jul 2005 12:14 AM
Dennis
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. 
--
Dennis in Houston


Show quoteHide quote
"Ken Tucker [MVP]" wrote:

> 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
>
> -----------------------------
>
> "Dennis" <Den***@discussions.microsoft.com> wrote in message
> news:9247C07B-8759-4737-9760-E84C25851E62@microsoft.com...
> 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?
>
> --
> Dennis in Houston
>
>
>