Marshalling a byte array from EVC3 DLL to VB.NETCF

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have a evc3.0 dll written to handle an internal camera. In the following
function from the dll:

HRESULT hpCamPReviewGetBGR16(HANDLE hCamera, LPBYTE pBuffer);

The 'pBuffer' is a pointer to a buffer to receive the preview frame. The
size of the buffer needs to be width X height X 2.

I need to know how to work with this in VB.NetCF?

Dim pBuffer(614400) as byte
hpCamPreviewGetBGR16(hCamera, pBuffer)

How do I pass the array?

Any thoughts would be greatly appreciated and thanks in advance.
 
You're on the right course. Just make sure it's declared it a byte array in
the P/Invoke function.
 
Just like that. Passing Byte() works for function that take LPBYTE (or any
other pointer)
So, your code will work
 
So the function in the c++ dll is:
HRESULT hpCamPreviewGetBGR16(HANDLE hCamera, LPBYTE pBuffer)

How do I wrap this function in VB.NetCF to work?

Private Declare Function hpCamPreviewGetBGR16 Lib "hpcamapi.dll" ( _
ByRef hCamera As IntPtr, _
ByRef pBuffer As ?????) As UInt32

What type goes where I have placed the ????'s ?

Thanks in advance.


Alex Feinman said:
Just like that. Passing Byte() works for function that take LPBYTE (or any
other pointer)
So, your code will work
 
Private Declare Function hpCamPreviewGetBGR16 Lib "hpcamapi.dll" ( _
ByVal hCamera As IntPtr, _
ByVal pBuffer As Byte[]) As UInt32

Noble Bell said:
So the function in the c++ dll is:
HRESULT hpCamPreviewGetBGR16(HANDLE hCamera, LPBYTE pBuffer)

How do I wrap this function in VB.NetCF to work?

Private Declare Function hpCamPreviewGetBGR16 Lib "hpcamapi.dll" ( _
ByRef hCamera As IntPtr, _
ByRef pBuffer As ?????) As UInt32

What type goes where I have placed the ????'s ?

Thanks in advance.
 
Ok.
I assume that you meant for me to use Byte() rather than Byte[] since I am
dealing with VB and not C#?

In any event. That appears to have solved that problem.

Now, lastly do you know how to take this byte data and convert it to a
bitmap so that it can be displayed in a picturebox?

Thanks for all your help.


Alex Yakhnin said:
Private Declare Function hpCamPreviewGetBGR16 Lib "hpcamapi.dll" ( _
ByVal hCamera As IntPtr, _
ByVal pBuffer As Byte[]) As UInt32

Noble Bell said:
So the function in the c++ dll is:
HRESULT hpCamPreviewGetBGR16(HANDLE hCamera, LPBYTE pBuffer)

How do I wrap this function in VB.NetCF to work?

Private Declare Function hpCamPreviewGetBGR16 Lib "hpcamapi.dll" ( _
ByRef hCamera As IntPtr, _
ByRef pBuffer As ?????) As UInt32

What type goes where I have placed the ????'s ?

Thanks in advance.
 
If it's a valid image you can just create a Bitmap instance:

Dim ms as MemoryStream = New MemoryStream(pBuffer)

Dim bmp as Bitmap = New Bitmap(ms);

--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com
www.opennetcf.org
My blog: http://blog.opennetcf.org/ayakhnin

Noble Bell said:
Ok.
I assume that you meant for me to use Byte() rather than Byte[] since I am
dealing with VB and not C#?

In any event. That appears to have solved that problem.

Now, lastly do you know how to take this byte data and convert it to a
bitmap so that it can be displayed in a picturebox?

Thanks for all your help.


Alex Yakhnin said:
Private Declare Function hpCamPreviewGetBGR16 Lib "hpcamapi.dll" ( _
ByVal hCamera As IntPtr, _
ByVal pBuffer As Byte[]) As UInt32

Noble Bell said:
So the function in the c++ dll is:
HRESULT hpCamPreviewGetBGR16(HANDLE hCamera, LPBYTE pBuffer)

How do I wrap this function in VB.NetCF to work?

Private Declare Function hpCamPreviewGetBGR16 Lib "hpcamapi.dll" ( _
ByRef hCamera As IntPtr, _
ByRef pBuffer As ?????) As UInt32

What type goes where I have placed the ????'s ?

Thanks in advance.


:

Just like that. Passing Byte() works for function that take LPBYTE (or any
other pointer)
So, your code will work


--
Alex Feinman
---
Visit http://www.opennetcf.org
Hello,
I have a evc3.0 dll written to handle an internal camera. In the following
function from the dll:

HRESULT hpCamPReviewGetBGR16(HANDLE hCamera, LPBYTE pBuffer);

The 'pBuffer' is a pointer to a buffer to receive the preview frame. The
size of the buffer needs to be width X height X 2.

I need to know how to work with this in VB.NetCF?

Dim pBuffer(614400) as byte
hpCamPreviewGetBGR16(hCamera, pBuffer)

How do I pass the array?

Any thoughts would be greatly appreciated and thanks in advance.
 
Back
Top