The low level scanning functions allow greater control when acquiring images. In particular, you can control the number of pages acquired, whether the source shows its user interface, whether to use an Automatic Document Feeder, and the brightness, contrast and resolution of the scan.
When using the low level functions you need to call at a minimum:
After starting a TWAIN job using ScanLowInitTwainJob() you can also call the low level functions to specify scan parameters. These functions include:
These functions must be called after starting the job but before the ScanLowAcquirePages() function is called.
After calling ScanLowAcquirePages() an application must call the ScanLowCloseJob() function to free the resources allocated to the job.
This sample demonstrates how to use the low level scanning features. It demonstrates: Buffered Memory Transport, Duplex Enabled Scanners, and the use of the Logging Features.
The Imgman.h file may differ slightly from your original one. Updates have been added for the low level scanning functions. Sometimes you may need to uncomment these calls.
This example is written in the older Petzold style. While this is arcane it strips off all of the other fluff that might get in the way of an app that might possibly work with more than one compiler?
This is an example of a typical call to ScanLowAcquirePages:
case IDM_SCAN_SCAN_UI:
{
HANDLE hTwainJob;
hTwainJob = ScanLowInitTwainJob(hwnd);
ScanLowAcquirePages(hTwainJob, 255, TWAIN_BW, TWAIN_SHOWUI|TWAIN_USEADF, NULL);
ScanLowCloseJob(hTwainJob);
return 0;
}
This is the handler (also in the windows proc):
case WM_IMSCAN:
{
static nCount;
if (wParam)
{
HANDLE himg;
HANDLE hOptBlk = NULL;
if(himg = ImgFromDIB((HANDLE)wParam))
{
hOptBlk = ImgXOptBlkCreate(NULL);
ImgXOptBlkAdd(hOptBlk, "COMPRESS", "ON");
ImgXOptBlkAdd(hOptBlk, "TIFF_COMPRESS", "GROUP4");
ImgXOptBlkAdd(hOptBlk, "APPEND", "ON");
ImgXWriteImage("c:\\scantst.dcx", "dcx", himg, hOptBlk, NULL, NULL);
ImgXOptBlkDel(hOptBlk);
}else{
GlobalFree((void*)wParam);
}
}
return 0;
}
This handler simply appends the image to a file. In MFC just create a message map for the WM_IMSCAN event. Later on in the WM_IMTWAIN event Imageman handles opening the file and displaying it. Not that the WM_IMTWAIN event simply reports the TWAIN states the scanner/data source manager/application are going through. Starts at 2 climbs to 7 and back to 1 on a successful scan.
© 1995-2004 Data Techniques, Inc. All rights reserved.