User`s guide
5 Acquiring Image Data
5-22
Your thread function must accept a single parameter, which is defined as a pointer to
the object itself, i.e., the this pointer. The thread function returns a value that indicates
success or failure. For more information, see the documentation at the Microsoft
Developer Network Web site (msdn.microsoft.com).
The following is an acquisition thread function that you can use with the example
MyDeviceAdaptor. Replace the skeletal implementation you used in “Starting an
Acquisition Thread” on page 5-10 with this code.
DWORD WINAPI MyDeviceAdaptor::acquireThread(void* param) {
MyDeviceAdaptor* adaptor = reinterpret_cast<MyDeviceAdaptor*>(param);
MSG msg;
while (GetMessage(&msg,NULL,0,0) > 0) {
switch (msg.message) {
case WM_USER:
// Check if a frame needs to be acquired.
while(adaptor->isAcquisitionNotComplete()) {
// Insert Device-specific code here to acquire frames
// into a buffer.
if (adaptor->isSendFrame()) {
// Get frame type & dimensions.
imaqkit::frametypes::FRAMETYPE frameType =
adaptor->getFrameType();
int imWidth = adaptor->getMaxWidth();
int imHeight = adaptor->getMaxHeight();
// Create a frame object.
imaqkit::IAdaptorFrame* frame =
adaptor->getEngine()->makeFrame(frameType,
imWidth,
imHeight);
// Copy data from buffer into frame object.
frame->setImage(imBuffer,
imWidth,
imHeight,
0, // X Offset from origin
0); // Y Offset from origin
// Set image's timestamp.
frame->setTime(imaqkit::getCurrentTime());
// Send frame object to engine.
adaptor->getEngine()->receiveFrame(frame);
} // if isSendFrame()
// Increment the frame count.
adaptor->incrementFrameCount();