Converting BitMap to Icon

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dennis

    Converting BitMap to Icon

    I have a bitmap and make the color transparent;

    mybitmap.MakeTr ansparent(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
  • Ken Tucker [MVP]

    #2
    Re: Converting BitMap to Icon

    Hi,

    Even when I save a icon with its back color as color.transpare nt 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.FromIm age(bm)

    g.Clear(Color.T ransparent)

    g.FillEllipse(B rushes.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.FileS tream("Test.ico ", IO.FileMode.Cre ate)

    ico.Save(fs)

    fs.Close()



    Ken

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

    "Dennis" <Dennis@discuss ions.microsoft. com> wrote in message
    news:9247C07B-8759-4737-9760-E84C25851E62@mi crosoft.com...
    I have a bitmap and make the color transparent;

    mybitmap.MakeTr ansparent(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


    Comment

    • Dennis

      #3
      Re: Converting BitMap to Icon

      Thanks I'll try it.
      --
      Dennis in Houston


      "Ken Tucker [MVP]" wrote:
      [color=blue]
      > Hi,
      >
      > Even when I save a icon with its back color as color.transpare nt 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.FromIm age(bm)
      >
      > g.Clear(Color.T ransparent)
      >
      > g.FillEllipse(B rushes.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.FileS tream("Test.ico ", IO.FileMode.Cre ate)
      >
      > ico.Save(fs)
      >
      > fs.Close()
      >
      >
      >
      > Ken
      >
      > -----------------------------
      >
      > "Dennis" <Dennis@discuss ions.microsoft. com> wrote in message
      > news:9247C07B-8759-4737-9760-E84C25851E62@mi crosoft.com...
      > I have a bitmap and make the color transparent;
      >
      > mybitmap.MakeTr ansparent(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
      >
      >
      >[/color]

      Comment

      • Dennis

        #4
        Re: Converting BitMap to Icon

        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


        "Ken Tucker [MVP]" wrote:
        [color=blue]
        > Hi,
        >
        > Even when I save a icon with its back color as color.transpare nt 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.FromIm age(bm)
        >
        > g.Clear(Color.T ransparent)
        >
        > g.FillEllipse(B rushes.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.FileS tream("Test.ico ", IO.FileMode.Cre ate)
        >
        > ico.Save(fs)
        >
        > fs.Close()
        >
        >
        >
        > Ken
        >
        > -----------------------------
        >
        > "Dennis" <Dennis@discuss ions.microsoft. com> wrote in message
        > news:9247C07B-8759-4737-9760-E84C25851E62@mi crosoft.com...
        > I have a bitmap and make the color transparent;
        >
        > mybitmap.MakeTr ansparent(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
        >
        >
        >[/color]

        Comment

        Working...