By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,269 Members | 1,509 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,269 IT Pros & Developers. It's quick & easy.

Problems converting icons to IPictureDisp

P: n/a
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(fi leImage))

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

Any help greatly appreciated!

Thanks,

Cary


Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Map Reader wrote:
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?

--
Larry Lard
Replies to group please

Nov 21 '05 #2

P: n/a
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:
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(fi leImage))

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

Any help greatly appreciated!

Thanks,

Cary


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.