Unless you have a specific need for COM, you are probably better off
wrapping it in managed C++.

I *think* that particular bitmap constructor copies the pixels although
the documentation doesn't say, so you are probably safe to pass the
pointer as an int and cast it to an IntPtr
  Andrew

-----Original Message-----
From: Unmoderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Kirk Marple
Sent: Tuesday, June 21, 2005 3:15 PM
To: [email protected]
Subject: [Spam:***** SpamScore] [ADVANCED-DOTNET] COM interop with .NET
byte arrays?

i'm wrapping an unmanaged C++ API in a COM library (using ATL), so i can
more easily do interop with C#.

one of the APIs i'm wrapping uses a C++ data structure containing an
unsigned char* field.   I'm looking for the best way to pass this back
to
.NET.

I've gotten it working using a SAFEARRAY, constructed in the ATL DLL,
and
returned as an Array to .NET, but this entails two extra buffer copies
(one
into the SAFEARRAY, and one into an unmanaged buffer in .NET for
constructing a Bitmap class).

Is there an easy way to expose the unmanaged 'unsigned char*' pointer
from
the ATL DLL (as an IntPtr), so I can use it directly in the Bitmap class
constructor?

thanks for any help,
Kirk

-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Kirk Marple
Chief Software Architect, VP of Engineering
Agnostic Media, Inc.
e: [EMAIL PROTECTED]
w: www.agnostic-media.com
blog: http://sqljunkies.com/WebLog/kmarple

You can get my Digital ID here:
https://digitalid.verisign.com/services/client/index.html

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


BEGIN-ANTISPAM-VOTING-LINKS
------------------------------------------------------
Teach CanIt if this mail (ID 4316110) is spam:
Spam:
http://mail-gw.cognex.com/canit/b.php?c=s&i=4316110&m=9b8f7ff35d96
Not spam:
http://mail-gw.cognex.com/canit/b.php?c=n&i=4316110&m=9b8f7ff35d96
Forget vote:
http://mail-gw.cognex.com/canit/b.php?c=f&i=4316110&m=9b8f7ff35d96
------------------------------------------------------
END-ANTISPAM-VOTING-LINKS

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to