Honeywell and 5380 Frozen Dessert Maker User Manual


 
6 - 6
}
// Remember to delete your buffer.
delete [ ] image.puchBuffer;
Sample 8 - An asynchronous image capture using Windows Messaging
Note: You must hook the message WM_HHP_PROGRESS_HWND_MSG in your message loop to receive a barcode event
notification. Here, assume the message is hooked to call OnEventMsg.
// Capture image specifies:
for capture - none (use imager config settings)
for transfer - subsample value of 2 and JPEG transfer, progress notification
HHP_IMAGE_TRANSFER imgTrans; // Image transfer options (override
imager config)
TCHAR tcErrMsg[ 128 ]; // Error message buffer.
Result_t nResult = RESULT_ERR_INTIALIZE; // Return code.
extern DWORD g_dwPercentComplete = NULL; // Percent complete updated by SDK.
// Make sure to set imgTrans structure size!
imgTrans.dwStructSize = sizeof( HHP_IMAGE_TRANSFER );
// Set the subsample, compression, and, since you’re specifying lossy compression (JPEG),
add the compression factor masks. You are also asking to receive both a Windows message
with progress information, as well as having the SDK update a DWORD with the percentage
of transfer completion. For the latter, it is important the DWORD not lose scope or be
deleted before the asynchronous call completes. You might have a thread or timer that
looks at this value periodically before altering the user.
ImgTrans.dwMask =( SUBSAMPLE_VALUE_MASK | COMPRESSION_MODE_MASK | COMPRESSION_FACTOR_MASK
| TRANSFER_UPDATE_HWND | TRANSFER_UPDATE_DWORD);
// Set values
imgTrans.dwSubSample = 2; // Every other pixel and every other
row.
imgTrans.compressionMode = COMPRESSION_LOSSY; // Image compression lossy which is
mode 1 JPEG lossy.
imgTrans.compressionFactor = 95; // Image compression factor (image
quality) of 95%.
ImgTrans. hTransferNotifyHwnd = GetSafeHwnd(); // Set this to the window handle you
wish to receive the progress message.
imgTrans.dwPercentComplete = &g_dwPercentComplete; //Tell SDK to update this DWORD as
data is received.
// Call the SDK function to capture an image setting the bWait parameter to FALSE for
asynchronous behavior.
if ( (nResult = hhpAcquireImage( NULL,&imgTrans,NULL,FALSE ) == RESULT_SUCCESS )
{
// Display the image. NOTE: You could specify FF_BMP_GRAY. The data would come as
a BMP file.
}
else
{
hhpGetErrorMessage( nResult,tcErrMsg );
_tprintf( _T(“Image Capture Failed: %s\n”),tcErrMsg );
}
// Message Handler for transfer progress message
LRESULT OnProgressMsg( WPARAM wParam,LPARAM lParam )
{
DWORDdwBytesSoFar = wParam;// Number of bytes receive to this point.
DWORDdwBytesToRead = lParam;// Total number of bytes expected.