LTwain::FastAcquire

#include "ltwrappr.h"

L_INT LTwain::FastAcquire (pszBaseFileName, uFlags, uTransferMode, nFormat, nBitsPerPixel, bMultiPageFile, uUserBufSize, bUsePreferredBuffer)

Acquires image(s) from a TWAIN source and stores the image file(s) using the Fast TWAIN feature. This function is available in the Document/Medical Toolkits.

Parameters

L_TCHAR * pszBaseFileName

Character string that contains the base name of the image file(s) in which to save the acquired data.

L_UINT uFlags

Flag that indicates whether to display the manufacturer's user interface. 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] Show the manufacturer's user interface as modeless.
LTWAIN_MODAL_USER_INTERFACE [0x0002] Show 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.

 

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

L_INT nFormat

Output file format. Valid values depend on the transfer mode used.

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_BOOL bMultiPageFile

Flag that indicates whether to save multiple images into a single multipage file (if the output file format supports multipage files), or each page in a separate file. Possible values are:

Value Meaning
TRUE Save in one multipage file.
FALSE Save in separate files.

L_UINT32 uUserBufSize

Specifies a user-defined buffer size. This value is valid only if uTransferMode is LTWAIN_BUFFER_MODE and bUsePreferredBuffer is FALSE. This value must be a multiple of 16.

L_BOOL bUsePreferredBuffer

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.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

Based on the scanner type, this function determines the best and fastest scanning method to use. This method is used for actual scanning (as opposed to testing) of the image(s). Call LTwain::FindFastConfig before calling this function to retrieve the best scanning configuration in the pOutBestConfig parameter, and then pass the values of the members in pOutBestConfig to this function.

If the file format specified in nFormat does not support multipage files, the value of bMultiPageFile will be ignored and the function will automatically save the acquired images in separate files. The naming of the files will be carried out as follows: if the string in pszBaseFileName is "Temp.jpg", 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.

Should more than 9,999 pages be acquired, numbering switches to using the actual page number. So after "Temp9999.jpg", the next page scanned would be named "Temp10000.jpg", and the following page would be "Temp10001.jpg", etc. After "Temp99999.jpg", the next page scanned would be named "Temp100000.jpg", and the following page would be "Temp100001.jpg", etc.

If the file format supports multipage files, this function will use the bMultiPageFile parameter to determine how to save multiple images. If bMultiPageFile is 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 the exact string used in pszBaseFileName (e.g., "Temp.jpg") and it will be saved as a multipage file.

To cancel the acquire operation call LTwain::CancelAcquire.

To stop acquiring images only from the feeder of the TWAIN source, call LTwain::StopFeeder within the LTwain::AcquireCallBack function when it is fired.

You can achieve the same functionality to this function by using the LTwain::AcquireMulti.

The LTWAIN_KEEPOPEN flag works only in the following cases:

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

Required DLLs and Libraries

See Also

Functions

Topics

Example

L_VOID CFastTwain::AcquireCallBack(L_INT nPage, L_TCHAR* pszFileName, L_BOOL bFinishScan) 
{ 
   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 LTwain__FastAcquireExample(HWND hWnd, CFastTwain *MyClass) 
{ 
   L_INT             nRet; 
   L_BOOL            bAvailable; 
   APPLICATIONDATA   AppData; 
 
   /* Check to see if TWAIN is installed */ 
 
   bAvailable = MyClass->IsAvailable(); 
   if (bAvailable) 
   { 
      ZeroMemory(&AppData,sizeof(AppData)); 
      AppData.uStructSize = sizeof(AppData); 
 
      AppData.hWnd = hWnd;  
      lstrcpy (AppData.szManufacturerName, TEXT("LEAD Technologies, Inc."));  
      lstrcpy (AppData.szAppProductFamily, TEXT("LEAD Test Applications")); 
      lstrcpy (AppData.szVersionInfo, TEXT("Version 1.0")); 
      lstrcpy (AppData.szAppName, TEXT("TWAIN Test Application")); 
 
      nRet = MyClass->InitSession(&AppData);  
      if(nRet != SUCCESS) 
         return nRet; 
   } 
 
   MyClass->EnableCallBack (TRUE); 
 
   nRet = MyClass->FastAcquire( 
                              MAKE_IMAGE_PATH(TEXT("test.bmp")), 
                              LTWAIN_SHOW_USER_INTERFACE, 
                              LTWAIN_FILE_MODE, 
                              FILE_BMP, 
                              1, 
                              TRUE, 
                              0,  
                              TRUE); 
 
   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 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

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