472,119 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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_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
2 5967

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
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.

Similar topics

1 post views Thread by john | last post: by
2 posts views Thread by Stephen Turner | last post: by
1 post views Thread by Zubair.NET! | last post: by
1 post views Thread by =?Utf-8?B?WWFlbA==?= | last post: by
reply views Thread by =?Utf-8?B?WWFlbA==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.