473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

COM StdPicture-to-Image conversion

We're authoring a VS 2005 app that includes several EXE's and DLL's and also
uses a COM component (a customer requirement). The COM component provides a
graphic image to be used by the .NET app; the graphic is supplied as a
"StdPicture" (AKA, IPictureDisp).

How can I convert this to a .NET Image? A search of the object browser
shows:

protected static System.Drawing.Image GetPictureFromIPictureDisp(object
picture)
Member of System.Windows.Forms.AxHost

and in VB.NET
Microsoft.VisualBasic.Compatibility.VB6.IPictureDi spToImage

Is there any other, more workable way to accomplish this conversion?

TIA ...
Apr 29 '06 #1
4 3193
>Is there any other, more workable way to accomplish this conversion?

What do you mean by "more workable"? What's wrong with the method you
listed?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Apr 29 '06 #2
Hi Mattias,

Thanks for responding.

Of these two methods, using the AxHost method would appear to be a kludge -
or at least inappropriate - for a library (DLL), as I think it would require
a control on a windows form.

And using the VB6 compatibility layer of VB.NET just seems kind-of ...
silly? ... for a C# library.

I'm sure I must be missing something ... but I just don't see what that is!

--Mark

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:u7**************@TK2MSFTNGP03.phx.gbl...
Is there any other, more workable way to accomplish this conversion?


What do you mean by "more workable"? What's wrong with the method you
listed?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Apr 30 '06 #3
You don't need a control on a form, you just need a class that derives from
AxHost so that you can call the appropriate protected static methods. This
will create a dependency on System.Windows.Forms.dll.

The alternative is to create a managed definition for IPictureDisp so that
you can retrieve the GDI handle of the picture object. You can then use this
handle to create an appropriate GDI+ image, e.g. Image.FromHbitmap,
Icon.FromHandle, etc.

--
Kevin Westhead

"Mark" <ma******@blaisesoft-xxx.com> wrote in message
news:Oh**************@TK2MSFTNGP02.phx.gbl...

<snip>

Of these two methods, using the AxHost method would appear to be a
kludge - or at least inappropriate - for a library (DLL), as I think it
would require a control on a windows form.

And using the VB6 compatibility layer of VB.NET just seems kind-of ...
silly? ... for a C# library.

<snip>


Apr 30 '06 #4
DUH! - you're right Kevin - I missed the "static" attribute.

Thanks

"Kevin Westhead" <sp*********@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
You don't need a control on a form, you just need a class that derives
from AxHost so that you can call the appropriate protected static methods.
This will create a dependency on System.Windows.Forms.dll.

The alternative is to create a managed definition for IPictureDisp so that
you can retrieve the GDI handle of the picture object. You can then use
this handle to create an appropriate GDI+ image, e.g. Image.FromHbitmap,
Icon.FromHandle, etc.

--
Kevin Westhead

"Mark" <ma******@blaisesoft-xxx.com> wrote in message
news:Oh**************@TK2MSFTNGP02.phx.gbl...

<snip>

Of these two methods, using the AxHost method would appear to be a
kludge - or at least inappropriate - for a library (DLL), as I think it
would require a control on a windows form.

And using the VB6 compatibility layer of VB.NET just seems kind-of ...
silly? ... for a C# library.

<snip>

May 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Geoff | last post by:
In this code I am trying to pass an image, as a parameter, out of the procedure PickCard. The code will not support this. How do I pass an image as a parameter? Thanks again Geoff
17
dbanning
by: dbanning | last post by:
I am trying to save the contents of a form as a bitmap and am unsure how to do this. I can use the savepicture command to save the form as a bitmap but the contents is not intact as you would expect....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.