L_TwainFindFastConfig

Summary

Determines the best scanner configuration.

Syntax

#include "lttwn.h"

L_LTTWN_API L_INT L_TwainFindFastConfig(hSession, pszWorkingFolder, uFlags, nBitsPerPixel, nBufferIteration, pInFastConfigs, nInFastConfigsCount, ppTestConfigs, pnTestConfigsCount, pOutBestConfig, uStructSize, pfnCallBack, pUserData)

Parameters

HTWAINSESSION hSession

Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession or L_TwainInitSession2 function.

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 appear 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 BitsPerPixel 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 test 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

Size in bytes, of the structures pointed to by pInFastConfigs, ppTestConfigs, and pOutBestConfig, for versioning. Use sizeof(FASTCONFIG).

LTWAINFINDFASTCONFIG pfnCallBack

Optional callback function, called for each scan configuration as it is tested.

The callback function must adhere to the function prototype described in the LTWAINFINDFASTCONFIG function.

L_VOID *pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure. If the additional parameters are not needed, you can pass NULL in this parameter.

Returns

Value Meaning
SUCCESS The function was successful.
! = SUCCESS An error occurred. Refer to Return Codes.

Comments

This function will test scan configurations for the scanner selected by calling L_TwainSelectSource. It will update the pOutBestConfig parameter with the best scan configuration tested. After 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 L_TwainAcquireMulti so the images can be scanned as quickly as possible.

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 L_TwainFreeScanConfig.

The LTWAIN_KEEPOPEN flag works only in the following cases:

  1. Passed with LTWAIN_SHOW_USER_INTERFACE flag to make the TWAIN user-interface appears as a 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 a modal dialog. The TWAIN data source remains open after scanning until the user closes it.

This function shows some helper message boxes while its running guiding the user through the running tests, if you wish to suppress these message then pass LTWAIN_SUPPRESS_MESSAGE_BOXES flag and these messages will stop showing up.

Required DLLs and Libraries

See Also

Functions

Topics

Example

For an example, refer to L_TwainFindFastConfig.

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

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