C# - getting binary data from .lib
- From: "Stephen Cawood" <cawood@xxxxxxxxxx>
- Date: Sat, 03 Jun 2006 03:41:51 GMT
I posted this question a few days ago, but it hasn't been resolved so I'm
trying again (with better info).
I'm trying to access a C++ .lib from C#. I can get an int back fine, the
problem I'm having is returning an array of binary data. any ideas?
thanks in advance...
..lib contains this function:
/-Call create() to create a bitmap of (10*scale) x (*10*scale) bytes
//create() will fill an unsigned char array with 100*scale*scale bytes
//
//create ID=567, 5 pixels/bit, total image will be 50x50 pixels
//this function will malloc room if image is NULL
//returns -1 if problem, 0 otherwise
int create(int id, int scale, unsigned char *image);
wrapper DLL:
WIN32DLL_API int create_wrapped(int id, int scale, unsigned char *image)
{
return create(id, scale, image);
}
[DllImport("Wrapper.dll", EntryPoint="create_wrapped")]
public static extern int create_wrapped(int id, int scale, byte[] image);
byte[] bArray = new byte[500];
create_wrapped(0,5,bArray); //bArray = array of zeros
notes:
I've also tried...
public static extern int create_wrapped(int id, int scale,
[Out][MarshalAs(UnmanagedType.LPArray, SizeConst=500)]byte[] image);
//bArray = array of zeros
public static extern int create_wrapped(int id, int scale,
[MarshalAs(UnmanagedType.LPArray)]byte[] image); //bArray = array of zeros
public static extern int create_wrapped(int id, int scale,[Out] IntPtr
image); //returns -1 failure
.
- Follow-Ups:
- Re: C# - getting binary data from .lib
- From: Michael Phillips, Jr.
- Re: C# - getting binary data from .lib
- From: lgs.lgs
- Re: C# - getting binary data from .lib
- Prev by Date: Re: Interop Memory Leak....
- Next by Date: Re: C# - getting binary data from .lib
- Previous by thread: Re: Excel Add ins does not work with .NET 2.0
- Next by thread: Re: C# - getting binary data from .lib
- Index(es):
Relevant Pages
|