LTwain::FindFastConfig

Summary

Determines the best scanner configuration.

This function is available in the Document/Medical Toolkits.

Syntax

#include "ltwrappr.h"

virtual L_INT LTwain::FindFastConfig(pszWorkingFolder, uFlags, nBitsPerPixel, nBufferIteration, pInFastConfigs, nInFastConfigsCount, ppTestConfigs, pnTestConfigsCount, pOutBestConfig, uStructSize)

Parameters

L_TCHAR * pszWorkingFolder

Character string containing the path to the working folder in which to save the tested images.

L_UINT 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] Show the manufacturer's user interface as modeless.
LTWAIN_MODAL_USER_INTERFACE [0x0002] Show 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.
LTWAIN_SUPPRESS_MESSAGE_BOXES [0x0100] Suppress message boxes that show up before the manufacturer's user interface dialog.

L_INT 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 bits per pixel value supported by that format.

L_INT nBufferIteration

This value is used to determine the number of memory configurations that will be tested. The maximum value for this parameter is 10.

pFASTCONFIG pInFastConfigs

Pointer to a FASTCONFIG structure that contains an array of scan configurations to be tested. Pass NULL to test the default scan configurations.

L_INT nInFastConfigsCount

Number of scan configurations referenced in pInFastConfigs. Pass 0 to test the default scan configurations.

pFASTCONFIG *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.

L_INT *pnTestConfigsCount

Pointer to an integer variable to be updated with the number of tested configurations.

pFASTCONFIG pOutBestConfig

Pointer to a FASTCONFIG structure to be updated with the best configuration for the scanner.

L_UINT uStructSize

Specifies the size of the FASTCONFIG structure in bytes, for versioning. Use sizeof(FASTCONFIG).

Returns

Value Meaning
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 quickly 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 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 threads 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 the 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, free the storage by calling LTwain::FreeScanConfig.

The LTWAIN_KEEPOPEN flag works only in the following cases:

  1. Passed with thr LTWAIN_SHOW_USER_INTERFACE flag to make the TWAIN user-interface appear as a modeless dialog. The TWAIN data source remains open after scanning until the user closes it.
  2. Passed with the LTWAIN_SHOW_USER_INTERFACE and LTWAIN_MODAL_USER_INTERFACE flags to make the TWAIN user-interface appear as a modal dialog. The TWAIN data source remains open after scanning until the user closes it.

This function shows some helper message boxes while it is running, guiding the user through the running tests. To suppress these messages, pass the LTWAIN_SUPPRESS_MESSAGE_BOXES flag and these messages will stop appearing.

Required DLLs and Libraries

See Also

Functions

Topics

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(MAKE_IMAGE_PATH(TEXT("")), 
                                  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; 
 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS TWAIN C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.