L_TwainFastAcquire2

   

#include "lttwn.h"

L_LTTWN_API L_INT L_TwainFastAcquire2(hSession, pszBaseFileName, nStartPageNumber, uFlags, uTransferMode, nFormat, nBitsPerPixel, bMultiPageFile, uUserBufSize, bUsePrefferedBuffer, pfnCallBack, pUserData)

HTWAINSESSION hSession;

handle to an existing TWAIN session

L_TCHAR * pszBaseFileName;

base string

L_INT nStartPageNumber;

start page number

L_UINT uFlags;

flags

L_UINT uTransferMode;

transfer mode

L_INT nFormat;

output file format

L_INT nBitsPerPixel;

resulting files pixel depth

L_BOOL bMultiPageFile;

multi-page flag

L_UINT32 uUserBufSize;

user-defined buffer size

L_BOOL bUsePrefferedBuffer;

buffer size flag

LTWAINACQUIRECALLBACK pfnCallBack;

optional callback function

L_VOID * pUserData;

pointer to more parameters for the callback

Acquires image(s) from a TWAIN source and stores the image file(s) using Fast TWAIN feature.

Parameter Description
hSession Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession or L_TwainInitSession2 function.
pszBaseFileName Character string containing the base name of the image file(s) in which to save the acquired data.
nStartPageNumber The starting page number where the numbering of the newly scanned files names starts. For example, if this parameter has the value 3 then the scanned files will have the name "BaseFileName_0003.bmp".

Pass -1 for this parameter to start numbering files from page 1, which in this case for the first scanned file it will have the format "BaseFileName_0001.bmp".

uFlags Flag that indicates whether to display the manufacturer's user interface. You can combine values when appropriate by using a bitwise OR ( | ). The following are valid values:
  Value Meaning
  0 [0] Do not show the manufacturer's user interface.
  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. It is valid only if the LTWAIN_SHOW_USER_INTERFACE flag is set.
  LTWAIN_KEEPOPEN [0x0020] Keep the TWAIN data source open after scanning.
uTransferMode Flag that indicates the transfer mode to be used when acquiring the image(s). Possible values are:
  Value Meaning
  LTWAIN_FILE_MODE [0x001] Use the File transfer mode.
  LTWAIN_BUFFER_MODE [0x002] Use the Memory transfer mode.
  LTWAIN_NATIVE_MODE [0x004] Use the Native transfer mode.
nFormat Output file format.
nBitsPerPixel Resulting file's pixel depth. Note that not all bits per pixel are available to all file formats. If nBitsPerPixel is set to 0, the file will be stored using the closest BitsPerPixel value supported by that format.
bMultiPageFile Flag that indicates whether to save multiple images into a single multi-page file (if the output file format supports multi-page files), or each page in a separate file. Possible values are:
  Value Meaning
  TRUE Save in one multi-page file.
  FALSE Save in a separate file.
uUserBufSize Specifies a user-defined buffer size. This value is valid only if uTransferMode is LTWAIN_BUFFER_MODE and bUsePrefferedBuffer is FALSE. This value must be a multiple of 16.
bUsePrefferedBuffer Flag that indicates whether to use the user-defined buffer size or the Twain driver preferred buffer size. Possible values are:
  Value Meaning
  TRUE Use the Twain driver preferred buffer size. The value of uUserBufSize will be ignored.
  FALSE Use the user-defined buffer size in the uUserBufSize parameter.
pfnCallBack Optional callback function, called twice for each page scan. The first call is to notify the page that the scanning has started, and the second call is to notify the page that the scanning has finished. If you do not provide a callback function, use NULL as the value of this parameter. No error reporting will occur. If you do provide a callback function, use the function pointer as the value of this parameter. The callback function must adhere to the function prototype described in the LTWAINACQUIRECALLBACK function.
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.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

You may call L_TwainFindFastConfig before calling this function to retrieve the best scanning configuration in pOutBestConfig parameter, and then pass the values of members in pOutBestConfig to this function.

This function was added in order to allow users to prevent already scanned files from being overwritten by a subsequent scan batch. This is accomplished by specifying the page number where the new files creation should start numbering files. If for example, three pages have been scanned while the specified pszBaseFileName parameter was "BaseFileName.bmp", the output files will have the names "BaseFileName_0001.bmp", "BaseFileName_0002.bmp" and "BaseFileName_0003.bmp". Starting a new scan while the nStartPageNumber is -1, then will overwrite the saved files. In order to avoid overwriting files, pass a 4 for the nStartPageNumber parameter so the new scanned files will start from 4. The resulting files will save as "BaseFileName_0004.bmp", "BaseFileName_0005.bmp", ...etc.

If the file format specified in nFormat does not support multi-page files, this function will ignore the bMultiPageFile parameter and automatically save the scanned images in separate files. The naming of the files will be carried out as follows: if the string in pszBaseFileName is "Temp.jpg", and the nStartPageNumber is -1, the method will append the number of the image, 0001, 0002, etc, to the name of the file. Therefore, the output file names will be "Temp0001.jpg", "Temp0002.jpg", etc. But if nStartPageNumber is not -1 (which should be any value bigger than zero), then the numbering will start from that value, so if for example the nStartPageNumber contains the value 4 then the output file names will be "Temp0004.jpg", "Temp0005.jpg", etc.

If the file format supports multi-page files, this function will use the bMultiPageFile parameter to determine how to save multiple images. If bMultiPageFile is set to FALSE, each scanned page will be saved to a separate file, named in the same manner described in the paragraph above. If bMultiPageFile is TRUE, the name of the output file will be exactly the string in pszBaseFileName "Temp.jpg" and it will be saved as a multi-page file.

To cancel the acquire operation call the L_TwainCancelAcquire.

To stop acquire images only from the feeder of the TWAIN source, call the L_TwainStopFeeder function.

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.

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.

Platforms

Windows 95 / 98 / Me, Windows 2000 / XP, Windows CE.

See Also

Functions:

L_TwainFastAcquire, L_TwainAcquire, L_TwainAcquireList, L_TwainInitSession, L_TwainEndSession, L_TwainOpenTemplateFile, L_TwainCloseTemplateFile, L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetNumofCapsInFile, L_TwainGetCapabilityFromFile, L_TwainFindFastConfig, L_TwainGetScanConfigs, L_TwainFreeScanConfig, L_TwainCancelAcquire, L_TwainStopFeeder

Topics:

How to Acquire from the TWAIN Source

 

TWAIN Functionality: Property Functions

Example

For complete sample, refer to FASTTWN demo.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_VOID EXT_CALLBACK FastAcquireCB(HTWAINSESSION hSession, 
L_INT         nPage, 
L_TCHAR*      pszFileName, 
L_BOOL        bFinishScan, 
L_VOID*       pUserData) 
{ 
   UNREFERENCED_PARAMETER(hSession); 
   UNREFERENCED_PARAMETER(pUserData); 
   L_TCHAR szTemp[MAX_PATH]; 
   if (bFinishScan) 
   { 
      wsprintf(szTemp, TEXT("The page # %d is scanned and saved to file name %s\n"), nPage, pszFileName); 
      MessageBox(NULL, szTemp, TEXT("Notice"), MB_OK); 
   } 
} 
L_INT TwainFastAcquire2Example(HWND hWnd,HTWAINSESSION hSession) 
{ 
   L_INT nRet; 
   nRet = L_TwainFastAcquire2(hSession, 
   MAKE_IMAGE_PATH(TEXT("test.tif")), 
   3, // start page number to use when numbering output file names, output files should be test_0003.tif, test_0004.tif, ...etc 
   LTWAIN_SHOW_USER_INTERFACE, 
   LTWAIN_BUFFER_MODE, 
   FILE_TIF, 
   1, 
   TRUE, 
   0, 
   FALSE, 
   FastAcquireCB, NULL); 
   if (nRet == SUCCESS) 
      MessageBox(hWnd, TEXT("Fast Twain function was successful"), TEXT("Notice"), MB_OK); 
   else 
      MessageBox(hWnd, TEXT("Error occurred during fast Twain function!!!"), TEXT("Error!!!"), MB_OK); 
   return nRet; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS TWAIN C API Help