Convert a structure to a byte array

J

Joey Wu

Dear All.

As title. How can I complete this?
Cause I have to use OpenNETCF.IO.StreamInterfaceDriver.DeviceIOControl to
get a CCD capture on my device.
The document show that I need pass some infos into driver with a structure.
Please give me a hand and thanks a lot~~!!
I have C++ sample code here
====================================
struct video_mmap
{
DWORD frame; //Reserved, no use here
WORD height,width; //specify the height and width to capture
DWORD format; //RGB15 = 6 //rgb16 = 3
};

typedef struct Capture {
BOOL Rflag, Wflag; //Reserved, not used.
BYTE ioctlBUF[VBUFSIZE]; //capture buffer passed to driver, returned
with captured image data
} BTVCapture;

struct video_mmap vm; //contain parameters and pass to driver
BTVCapture CAP; //capture buffer

DeviceIoControl(hFile, VIDIOCSYNC, &vm, sizeof(vm), CAP.ioctlBUF,
sizeof(CAP.ioctlBUF), NULL, NULL);
// description: generate a request to bt878 to capture a image and save the
image in the buffer "CAP.ioctlBUF"
// with buffer size "sizeof(CAP.ioctlBUF)". the maximan size is (512*480*2)
bytes. vm structure
// conatins informations of capture height, width, and color format.
====================================
 
P

Paul G. Tobey [eMVP]

You usually would do this by defining an operator on the structure's class
to perform the 'conversion'. I think that, if you look at the OpenNETCF
SDF, you'll find a *lot* of places where you can access the fields in a
structure, but the actual memory format is an array of bytes. I know that
many things in the .Net namespace are that way...

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top