LTwain::FindFastConfig
#include "ltwrappr.h"
virtual L_INT LTwain::FindFastConfig(pszWorkingFolder, uFlags, nBitsPerPixel, nBufferIteration, pInFastConfigs, nInFastConfigsCount, ppTestConfigs, pnTestConfigsCount, pOutBestConfig, uStructSize)
L_TCHAR * pszWorkingFolder; |
/* working folder path */ |
L_UINT uFlags; |
/* option flags */ |
L_INT nBitsPerPixel; |
/* bits per pixel */ |
L_INT nBufferIteration; |
/* buffer iteration count */ |
pFASTCONFIG pInFastConfigs; |
/* pointer to a structure */ |
L_INT nInFastConfigsCount; |
/* number of array elements */ |
pFASTCONFIG *ppTestConfigs; |
/* pointer to a pointer to a structure */ |
L_INT *pnTestConfigsCount; |
/* number of scan configurations tested */ |
pFASTCONFIG pOutBestConfig; |
/* pointer to a structure */ |
L_UINT uStructSize; |
/* size of the FASTCONFIG structure*/ |
Determines the best scanner configuration.
This function is available in the Document/Medical Toolkits.
Parameter |
Description |
|
pszWorkingFolder |
Character string containing the path to the working folder in which to save the tested images. |
|
uFlags |
Flags that control the display of the user interface and the actions of the function. Possible values are: |
|
|
Value |
Meaning |
|
LTWAIN_SHOW_USER_INTERFACE |
[0x0001] Shows the manufacturer's user interface as modeless. |
|
LTWAIN_MODAL_USER_INTERFACE |
[0x0002] Shows the manufacturer's user interface as a modal dialog. Works only if the LTWAIN_SHOW_USER_INTERFACE flag is set. |
|
LTWAIN_USE_THREAD_MODE |
[0x0008] Use the fast Thread mode. |
|
LTWAIN_CHECK_ALL_DEFAULT_BPP |
[0x0010] Test all supported BPP. |
|
LTWAIN_KEEPOPEN |
[0x0020] Keep the TWAIN data source open after scanning. |
nBitsPerPixel |
Resulting file's pixel depth. Note that not all bits per pixel are available to all file formats. For valid values, refer to Formats of Output Files. If nBitsPerPixel is 0, the file will be stored using the closest BitsPerPixel value supported by that format. |
|
nBufferIteration |
This value is used to determine the number of memory configurations that will be tested. The maximum value for this parameter is 10. |
|
pInFastConfigs |
Pointer to a FASTCONFIG structure that contains an array of scan configurations to be tested. Pass NULL to test the default scan configurations |
|
nInFastConfigsCount |
Number of scan configurations referenced in pInFastConfigs. Pass 0 to test the default scan configurations. |
|
ppTestConfigs |
Address of a pointer to a FASTCONFIG structure. The function will automatically allocate an array of FASTCONFIG structures using the total number of tested configurations. |
|
pnTestConfigsCount |
Pointer to an integer variable to be updated with number of tested configurations. |
|
pOutBestConfig |
Pointer to a FASTCONFIG structure to be updated with the best configuration for the scanner. |
|
uStructSize |
Specifies the size of the FASTCONFIG structure in bytes, for versioning. Use sizeof(FASTCONFIG). |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function will test scan configurations for the scanner selected by calling LTwain::SelectSource. It will update the pOutBestConfig parameter with the best scan configuration tested. Once the best scan configuration has been determined, the scan configuration's values for the transfer mode, bits per pixel, format and buffer size can be passed to LTwain::AcquireMulti or LTwain::FastAcquire so the images can be scanned as fast as possible.
To test user-defined/custom configurations, pass these configurations in pInFastConfigs and the number of configurations in nInFastConfigsCount.
To test the default configurations available for the Twain driver, pass NULL for pInFastConfigs and 0 for nInFastConfigsCount. In this case, the function will test scan configurations based the values passed in the nBitsPerPixel and nBufferIteration parameters.
The list of default scan configurations to test can be shortened by using the LTwain::GetScanConfigs function to get a list of default scan configurations based on transfer mode, bits per pixel and number of buffers. This list can then be passed to LTwain::FindFastConfig function to determine the best and fastest scan configuration.
If LTWAIN_CHECK_ALL_DEFAULT_BPP is set in uFlags then the function will test all supported bits per pixel for the selected scanner. If this flag is not set in uFlags, then the function will use the iBitsPerPixel parameter value.
If LTWAIN_USE_THREAD_MODE is set in uFlags, then the image acquisition process will run in thread mode. In some scanners, acquiring images in thread will improve the speed at which the image(s) is(are) acquired. In other scanners, high-speed scanners, for example, acquiring the image(s) in thread mode will provide little to no improvement in the speed at which the image(s) is(are) acquired.
The nBitsPerPixel parameter and LTWAIN_CHECK_ALL_DEFAULT_BPP flag will be used only if the transfer mode for the scan configuration being tested is LTWAIN_BUFFER_MODE or LTWAIN_NATIVE_MODE.
The nBufferIteration parameter will be used only if the transfer mode for the scan configuration being tested is LTWAIN_BUFFER_MODE.
If you override the LTwain::FindFastConfigCallBack function, the scan configuration testing process can be stopped by returning any value other than SUCCESS for the callback function. The testing process is continued by returning SUCCESS for the callback function.
This function allocates storage for the array of scan configurations in ppTestConfigs. When this storage is no longer needed, you must free the storage by calling LTwain::FreeScanConfig.
The LTWAIN_KEEPOPEN flag works only in the following cases:
1. |
Passed with LTWAIN_SHOW_USER_INTERFACE flag to make TWAIN user-interface appears as modeless dialog. The TWAIN data source remains open after scanning until the user closes it. |
2. |
Passed with LTWAIN_SHOW_USER_INTERFACE and LTWAIN_MODAL_USER_INTERFACE flags to make the TWAIN user-interface appears as modal dialog. The TWAIN data source remains open after scanning until the user closes it. |
Required DLLs and Libraries
LTTWN For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Example
// initialize session by LTwain::InitSession and call this function L_INT CMyTwain::FindFastConfigCallBack(pFASTCONFIG pResConfig) { L_TCHAR szBuffer[MAX_PATH]; if (pResConfig->bSuccess) { memset(szBuffer, 0, sizeof(szBuffer)); wsprintf(szBuffer, TEXT("Transfer Mode = %d\nFile Format = %d\nBuffer Size = %d\nRequired Time = %d\n"), pResConfig->uTransferMode, pResConfig->nFileFormat, pResConfig->ulBufferSize, pResConfig->uTime); MessageBox(NULL, szBuffer, TEXT("Result Scan Configuration..."), MB_OK); } else MessageBox(NULL, TEXT("The tested configuration failed"), TEXT("Error!"), MB_OK); return SUCCESS; } L_INT LTwain__FindFastConfigExample(HWND hWnd, CMyTwain *MyClass) { L_INT nRet; pFASTCONFIG pTestConfigs = NULL; L_INT nTestConfigsCount = 0; pFASTCONFIG pFastConfig=NULL; L_INT nFastConfigCount; FASTCONFIG BestConfig; L_TCHAR szBuffer[MAX_PATH]; MyClass->EnableCallBack (TRUE); nRet = MyClass->GetScanConfigs (1, LTWAIN_BUFFER_MODE, 5, &pFastConfig, sizeof(FASTCONFIG), &nFastConfigCount); if (nRet != SUCCESS) { MessageBox(hWnd, TEXT("Error occurred while getting the scan configurations for the Memory transfer mode!!!"), TEXT("Error!!!"), MB_OK); return nRet; } memset(&BestConfig, 0, sizeof(FASTCONFIG)); nRet = MyClass->FindFastConfig(TEXT("c:\\TWAIN"), LTWAIN_SHOW_USER_INTERFACE, 1, 5, pFastConfig, nFastConfigCount, &pTestConfigs, &nTestConfigsCount, &BestConfig, sizeof(FASTCONFIG)); if (nRet == SUCCESS) { MessageBox(hWnd, TEXT("LTwain::FindFastConfig function was successful."), TEXT("Notice"), MB_OK); memset(szBuffer, 0, sizeof(szBuffer)); wsprintf(szBuffer, TEXT("Transfer Mode = %d\nFile Format = %d\nBuffer Size = %d\nRequired Time = %d\n"), BestConfig.uTransferMode, BestConfig.nFileFormat, BestConfig.ulBufferSize, BestConfig.uTime); MessageBox(hWnd, szBuffer, TEXT("Best Scan Configuration..."), MB_OK); MyClass->FreeScanConfig(&pTestConfigs, nTestConfigsCount); } else { MessageBox(hWnd, TEXT("Error occurred in the L_TwainFindFastConfig function!!!"), TEXT("Error!!!"), MB_OK); return nRet; } nRet = MyClass->FreeScanConfig(&pFastConfig, nFastConfigCount); if(nRet != SUCCESS) return nRet; return SUCCESS; }