ICO to GIF? (transparant)

Discussion in 'ASP .Net' started by Edwin Knoppert, Dec 7, 2005.

  1. I'm trying to convert an icon handle to GIF.

    Something like:
    Public Function GetImageFromIconHandle(ByVal hIcon As Int32) As Int32
    Dim ico As Icon = Icon.FromHandle(hIcon)
    Dim x As New Drawing.IconConverter
    'x.ConvertTo(ico,typeof(System.Drawing.Imaging.ImageFormat.Gif) )
    End Function

    x.ConvertTo(ico, <requires a system.type> )

    I don't know how to do that.
    Important is that a transparent icon should remain transparent.

    hIcon is a valid 16x16 icon.
    Edwin Knoppert, Dec 7, 2005
    #1
    1. Advertising

  2. Have you tried typeof(Bitmap) ?

    --
    Daniel Fisher(lennybacon)
    http://www.lennybacon.com


    "Edwin Knoppert" <> wrote in message
    news:4396d335$0$2340$...
    > I'm trying to convert an icon handle to GIF.
    >
    > Something like:
    > Public Function GetImageFromIconHandle(ByVal hIcon As Int32) As Int32
    > Dim ico As Icon = Icon.FromHandle(hIcon)
    > Dim x As New Drawing.IconConverter
    > 'x.ConvertTo(ico,typeof(System.Drawing.Imaging.ImageFormat.Gif) )
    > End Function
    >
    > x.ConvertTo(ico, <requires a system.type> )
    >
    > I don't know how to do that.
    > Important is that a transparent icon should remain transparent.
    >
    > hIcon is a valid 16x16 icon.
    >
    >
    Daniel Fisher\(lennybacon\), Dec 7, 2005
    #2
    1. Advertising

  3. That would not work but..

    i already converted to bmp and i used that code.
    But the backcolor remains black while i added:
    Dim bmp As Bitmap = ico.ToBitmap
    bmp.MakeTransparent(Color.Black)
    Return bmp

    The image remains the same though.
    Better see a real example with a transparent ico > gif.

    Your suggestion:
    For the type i used: x.ConvertTo(ico, bmp.GetType)
    But i don't know what to use to draw to user, and even to expect a
    transparent gif since i still use a bitmap object (GIF is bitmap so i should
    give it a chance).

    Currently the BMP is shown:
    Response.ContentType = "image/gif"
    Dim xx As System.Drawing.Imaging.ImageFormat
    ' send the image to the viewer
    bmp.Save(Response.OutputStream, xx.Gif)

    bmp.Dispose()
    Response.End()



    "Daniel Fisher(lennybacon)" <> schreef in bericht
    news:Olcg11y%...
    > Have you tried typeof(Bitmap) ?
    >
    > --
    > Daniel Fisher(lennybacon)
    > http://www.lennybacon.com
    >
    >
    > "Edwin Knoppert" <> wrote in message
    > news:4396d335$0$2340$...
    >> I'm trying to convert an icon handle to GIF.
    >>
    >> Something like:
    >> Public Function GetImageFromIconHandle(ByVal hIcon As Int32) As Int32
    >> Dim ico As Icon = Icon.FromHandle(hIcon)
    >> Dim x As New Drawing.IconConverter
    >> 'x.ConvertTo(ico,typeof(System.Drawing.Imaging.ImageFormat.Gif) )
    >> End Function
    >>
    >> x.ConvertTo(ico, <requires a system.type> )
    >>
    >> I don't know how to do that.
    >> Important is that a transparent icon should remain transparent.
    >>
    >> hIcon is a valid 16x16 icon.
    >>
    >>

    >
    >
    Edwin Knoppert, Dec 7, 2005
    #3
  4. Making an image transparent in .NET is a rather complicated process, which I
    don't quite understand. Here is a page that I was referred to by someone in
    a newsgroup which is supposed to work. It is written in C#. I am a VB.NET
    coder, and I couldn't get it to work in that, but I think that is due to the
    unmanaged code capabilities of C#. I have not tried the code in C#, so I am
    assuming it would work if I did it in C#. See what it does for you. (If you
    do figure out a way to get it to work in VB.NET, could you let me know?)
    Here is the URL:

    http://ewbi.blogs.com/develops/2005/08/sparklines_22.html

    Good Luck!
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Edwin Knoppert" <> wrote in message
    news:4396deba$0$2342$...
    > That would not work but..
    >
    > i already converted to bmp and i used that code.
    > But the backcolor remains black while i added:
    > Dim bmp As Bitmap = ico.ToBitmap
    > bmp.MakeTransparent(Color.Black)
    > Return bmp
    >
    > The image remains the same though.
    > Better see a real example with a transparent ico > gif.
    >
    > Your suggestion:
    > For the type i used: x.ConvertTo(ico, bmp.GetType)
    > But i don't know what to use to draw to user, and even to expect a
    > transparent gif since i still use a bitmap object (GIF is bitmap so i
    > should give it a chance).
    >
    > Currently the BMP is shown:
    > Response.ContentType = "image/gif"
    > Dim xx As System.Drawing.Imaging.ImageFormat
    > ' send the image to the viewer
    > bmp.Save(Response.OutputStream, xx.Gif)
    >
    > bmp.Dispose()
    > Response.End()
    >
    >
    >
    > "Daniel Fisher(lennybacon)" <> schreef in bericht
    > news:Olcg11y%...
    >> Have you tried typeof(Bitmap) ?
    >>
    >> --
    >> Daniel Fisher(lennybacon)
    >> http://www.lennybacon.com
    >>
    >>
    >> "Edwin Knoppert" <> wrote in message
    >> news:4396d335$0$2340$...
    >>> I'm trying to convert an icon handle to GIF.
    >>>
    >>> Something like:
    >>> Public Function GetImageFromIconHandle(ByVal hIcon As Int32) As Int32
    >>> Dim ico As Icon = Icon.FromHandle(hIcon)
    >>> Dim x As New Drawing.IconConverter
    >>> 'x.ConvertTo(ico,typeof(System.Drawing.Imaging.ImageFormat.Gif) )
    >>> End Function
    >>>
    >>> x.ConvertTo(ico, <requires a system.type> )
    >>>
    >>> I don't know how to do that.
    >>> Important is that a transparent icon should remain transparent.
    >>>
    >>> hIcon is a valid 16x16 icon.
    >>>
    >>>

    >>
    >>

    >
    >
    Nathan Sokalski, Dec 7, 2005
    #4
  5. Thanks, will take a peek tomorrow :)

    It's a bit odd though, both types support tranparancy.
    So some conversion unit could 'know' what get's transparent (imo).
    Conversion to plain BMP first is prob.not ok.
    However dotnet has a maketransparent method, and i was hoping this would
    work at least.
    I did not see any difference.

    But hey.. what do i know? :)


    "Nathan Sokalski" <> schreef in bericht
    news:eaW0oQ3%...
    > Making an image transparent in .NET is a rather complicated process, which
    > I don't quite understand. Here is a page that I was referred to by someone
    > in a newsgroup which is supposed to work. It is written in C#. I am a
    > VB.NET coder, and I couldn't get it to work in that, but I think that is
    > due to the unmanaged code capabilities of C#. I have not tried the code in
    > C#, so I am assuming it would work if I did it in C#. See what it does for
    > you. (If you do figure out a way to get it to work in VB.NET, could you
    > let me know?) Here is the URL:
    >
    > http://ewbi.blogs.com/develops/2005/08/sparklines_22.html
    >
    > Good Luck!
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    > "Edwin Knoppert" <> wrote in message
    > news:4396deba$0$2342$...
    >> That would not work but..
    >>
    >> i already converted to bmp and i used that code.
    >> But the backcolor remains black while i added:
    >> Dim bmp As Bitmap = ico.ToBitmap
    >> bmp.MakeTransparent(Color.Black)
    >> Return bmp
    >>
    >> The image remains the same though.
    >> Better see a real example with a transparent ico > gif.
    >>
    >> Your suggestion:
    >> For the type i used: x.ConvertTo(ico, bmp.GetType)
    >> But i don't know what to use to draw to user, and even to expect a
    >> transparent gif since i still use a bitmap object (GIF is bitmap so i
    >> should give it a chance).
    >>
    >> Currently the BMP is shown:
    >> Response.ContentType = "image/gif"
    >> Dim xx As System.Drawing.Imaging.ImageFormat
    >> ' send the image to the viewer
    >> bmp.Save(Response.OutputStream, xx.Gif)
    >>
    >> bmp.Dispose()
    >> Response.End()
    >>
    >>
    >>
    >> "Daniel Fisher(lennybacon)" <> schreef in bericht
    >> news:Olcg11y%...
    >>> Have you tried typeof(Bitmap) ?
    >>>
    >>> --
    >>> Daniel Fisher(lennybacon)
    >>> http://www.lennybacon.com
    >>>
    >>>
    >>> "Edwin Knoppert" <> wrote in message
    >>> news:4396d335$0$2340$...
    >>>> I'm trying to convert an icon handle to GIF.
    >>>>
    >>>> Something like:
    >>>> Public Function GetImageFromIconHandle(ByVal hIcon As Int32) As Int32
    >>>> Dim ico As Icon = Icon.FromHandle(hIcon)
    >>>> Dim x As New Drawing.IconConverter
    >>>> 'x.ConvertTo(ico,typeof(System.Drawing.Imaging.ImageFormat.Gif) )
    >>>> End Function
    >>>>
    >>>> x.ConvertTo(ico, <requires a system.type> )
    >>>>
    >>>> I don't know how to do that.
    >>>> Important is that a transparent icon should remain transparent.
    >>>>
    >>>> hIcon is a valid 16x16 icon.
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Edwin Knoppert, Dec 7, 2005
    #5
  6. Don't let that make you feel too bad, my first attempt at transparency was
    to use the MakeTransparent method, too. To be honest, I think that there
    should be a method (or maybe a predefined Color, or maybe a separate class
    that inherits something from GDI+ that is used for making transparent
    images) that makes it simpler. Maybe if we're lucky that make one in a
    future release of .NET, because if you think about it, transparency is used
    in almost all gif images, I mean, when was the last time you saw a button or
    logo that was completely rectangular?
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Edwin Knoppert" <> wrote in message
    news:dn7m6e$n11$...
    > Thanks, will take a peek tomorrow :)
    >
    > It's a bit odd though, both types support tranparancy.
    > So some conversion unit could 'know' what get's transparent (imo).
    > Conversion to plain BMP first is prob.not ok.
    > However dotnet has a maketransparent method, and i was hoping this would
    > work at least.
    > I did not see any difference.
    >
    > But hey.. what do i know? :)
    >
    >
    > "Nathan Sokalski" <> schreef in bericht
    > news:eaW0oQ3%...
    >> Making an image transparent in .NET is a rather complicated process,
    >> which I don't quite understand. Here is a page that I was referred to by
    >> someone in a newsgroup which is supposed to work. It is written in C#. I
    >> am a VB.NET coder, and I couldn't get it to work in that, but I think
    >> that is due to the unmanaged code capabilities of C#. I have not tried
    >> the code in C#, so I am assuming it would work if I did it in C#. See
    >> what it does for you. (If you do figure out a way to get it to work in
    >> VB.NET, could you let me know?) Here is the URL:
    >>
    >> http://ewbi.blogs.com/develops/2005/08/sparklines_22.html
    >>
    >> Good Luck!
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>
    >> "Edwin Knoppert" <> wrote in message
    >> news:4396deba$0$2342$...
    >>> That would not work but..
    >>>
    >>> i already converted to bmp and i used that code.
    >>> But the backcolor remains black while i added:
    >>> Dim bmp As Bitmap = ico.ToBitmap
    >>> bmp.MakeTransparent(Color.Black)
    >>> Return bmp
    >>>
    >>> The image remains the same though.
    >>> Better see a real example with a transparent ico > gif.
    >>>
    >>> Your suggestion:
    >>> For the type i used: x.ConvertTo(ico, bmp.GetType)
    >>> But i don't know what to use to draw to user, and even to expect a
    >>> transparent gif since i still use a bitmap object (GIF is bitmap so i
    >>> should give it a chance).
    >>>
    >>> Currently the BMP is shown:
    >>> Response.ContentType = "image/gif"
    >>> Dim xx As System.Drawing.Imaging.ImageFormat
    >>> ' send the image to the viewer
    >>> bmp.Save(Response.OutputStream, xx.Gif)
    >>>
    >>> bmp.Dispose()
    >>> Response.End()
    >>>
    >>>
    >>>
    >>> "Daniel Fisher(lennybacon)" <> schreef in bericht
    >>> news:Olcg11y%...
    >>>> Have you tried typeof(Bitmap) ?
    >>>>
    >>>> --
    >>>> Daniel Fisher(lennybacon)
    >>>> http://www.lennybacon.com
    >>>>
    >>>>
    >>>> "Edwin Knoppert" <> wrote in message
    >>>> news:4396d335$0$2340$...
    >>>>> I'm trying to convert an icon handle to GIF.
    >>>>>
    >>>>> Something like:
    >>>>> Public Function GetImageFromIconHandle(ByVal hIcon As Int32) As Int32
    >>>>> Dim ico As Icon = Icon.FromHandle(hIcon)
    >>>>> Dim x As New Drawing.IconConverter
    >>>>> 'x.ConvertTo(ico,typeof(System.Drawing.Imaging.ImageFormat.Gif) )
    >>>>> End Function
    >>>>>
    >>>>> x.ConvertTo(ico, <requires a system.type> )
    >>>>>
    >>>>> I don't know how to do that.
    >>>>> Important is that a transparent icon should remain transparent.
    >>>>>
    >>>>> hIcon is a valid 16x16 icon.
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Nathan Sokalski, Dec 7, 2005
    #6
  7. Edwin Knoppert

    ABBSoft Team Guest

    ABBSoft Team, Dec 29, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hb
    Replies:
    6
    Views:
    9,118
  2. Patrick Olurotimi Ige

    Having favicon.ico instead of IE.ico on a website

    Patrick Olurotimi Ige, Dec 9, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,503
    Martin Dechev
    Dec 9, 2004
  3. Edwin Knoppert
    Replies:
    1
    Views:
    424
    Edwin Knoppert
    Dec 16, 2005
  4. Stijn Goris

    transparant color

    Stijn Goris, Dec 19, 2003, in forum: HTML
    Replies:
    9
    Views:
    1,291
    Toby A Inkster
    Dec 21, 2003
  5. Mel
    Replies:
    1
    Views:
    396
    Steve Pugh
    Mar 9, 2005
Loading...

Share This Page