Problems converting icons to IPictureDisp

M

Map Reader

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_strIconPath & strIcon)

fileImage.Save(g_strToolbarIconPath & "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.IPictureDispToImage(VB6.ImageToIPictureDisp(fileImage))

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



Any help greatly appreciated!

Thanks,

Cary
 
L

Larry Lard

Map said:
Greetings,

I am converting an old VB6 application to use .NET.
[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?
 
G

Guest

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top