Problems converting icons to IPictureDisp

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

    Problems converting icons to IPictureDisp

    Greetings,

    I am converting an old VB6 application to use .NET. One of the old controls
    loads icons from the disk and displays them. However, the transparent color
    turns to blue somewhere in the process. I narrowed it down to the conversion
    to IPictureDisp by first loading and saving the icon as a bitmap with no
    problems; and then repeating the process but adding the step of converting
    to an IPictureDisp as well. The first operation worked fine, the second
    resulted in an icon with a blue background. My question: How can I preserve
    the transparent color of the original icon while still converting to an
    IPictureDisp?

    Here's the code:

    'As a first step, just load and save the icon as a standard
    System.Drawing. Bitmap. Works fine and the icon looks unchanged.
    Dim fileImage = New System.Drawing. Bitmap(g_strIco nPath & strIcon)

    fileImage.Save( g_strToolbarIco nPath & "test.bmp")



    'Now save it again, but first convert the image to an IPictureDisp and then
    back again. Now we have a blue background!!

    fileImage = VB6.IPictureDis pToImage(VB6.Im ageToIPictureDi sp(fileImage))

    fileImage.Save( g_strIconPath & "test2.bmp" )



    Any help greatly appreciated!

    Thanks,

    Cary




  • Larry Lard

    #2
    Re: Problems converting icons to IPictureDisp


    Map Reader wrote:[color=blue]
    > Greetings,
    >
    > I am converting an old VB6 application to use .NET.[/color]
    [and problems are happening with IPictureDisp]

    Sorry, I don't have an actual answer, but only a suggestion that since
    you are converting away from VB6 then perhaps you would consider using
    Framework functionality rather than COM functionality such as
    IPictureDisp to do whatever it is you want to do?

    --
    Larry Lard
    Replies to group please

    Comment

    • Dennis

      #3
      RE: Problems converting icons to IPictureDisp

      I have tried to find a way to convert a bitmap to an icon while preserving
      the transparent color in the bitmap (spent two weekends on this) but
      failed...good luck. I think you have to get into the API and use CreateIcon
      but will need to know the transparent color first.
      --
      Dennis in Houston


      "Map Reader" wrote:
      [color=blue]
      > Greetings,
      >
      > I am converting an old VB6 application to use .NET. One of the old controls
      > loads icons from the disk and displays them. However, the transparent color
      > turns to blue somewhere in the process. I narrowed it down to the conversion
      > to IPictureDisp by first loading and saving the icon as a bitmap with no
      > problems; and then repeating the process but adding the step of converting
      > to an IPictureDisp as well. The first operation worked fine, the second
      > resulted in an icon with a blue background. My question: How can I preserve
      > the transparent color of the original icon while still converting to an
      > IPictureDisp?
      >
      > Here's the code:
      >
      > 'As a first step, just load and save the icon as a standard
      > System.Drawing. Bitmap. Works fine and the icon looks unchanged.
      > Dim fileImage = New System.Drawing. Bitmap(g_strIco nPath & strIcon)
      >
      > fileImage.Save( g_strToolbarIco nPath & "test.bmp")
      >
      >
      >
      > 'Now save it again, but first convert the image to an IPictureDisp and then
      > back again. Now we have a blue background!!
      >
      > fileImage = VB6.IPictureDis pToImage(VB6.Im ageToIPictureDi sp(fileImage))
      >
      > fileImage.Save( g_strIconPath & "test2.bmp" )
      >
      >
      >
      > Any help greatly appreciated!
      >
      > Thanks,
      >
      > Cary
      >
      >
      >
      >
      >[/color]

      Comment

      Working...