LTwain::AcquireMulti

#include "ltwrappr.h"

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

L_TCHAR L_FAR *pszBaseFileName;

/* base string */

L_UINT uFlags;

/* option flags */

L_UINT uTransferMode;

/* transfer mode */

L_INT nFormat;

/* output file format */

L_INT nBitsPerPixel;

/* resulting file’s pixel depth */

L_BOOL bMultiPageFile;

/* naming flag */

L_UINT32 uUserBufSize;

/* user-defined buffer size */

L_BOOL bUsePreferredBuffer;

/* buffer size flag */

Acquires one or more images from a TWAIN source and stores the images in the specified file(s). This function is available in the Document/Medical Toolkits.

Parameter

Description

pszBaseFileName

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

uFlags

Flag that indicates whether to display the manufacturer's user interface. Possible values are:

 

Value

Meaning

 

0

[0] Do not show the manufacturer's user interface.

 

LTWAIN_SHOW_USER_INTERFACE

[1] Shows the manufacturer's user interface as modeless.

 

LTWAIN_MODAL_USER_INTERFACE

[2] Shows the manufacturer's user interface as a modal dialog. Works only if the LTWAIN_SHOW_USER_INTERFACE flag is set.

 

LTWAIN_KEEPOPEN

[20] Keep the TWAIN data source open after scanning.

uTransferMode

Flag that indicates the transfer mode to use 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. For valid values, refer to Formats of Output Files.

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.

bMultiPageFile

Flag that indicates whether to save multiple images into a single multi-page file, or into a series of single page files. Possible values are:

 

Value

Meaning

 

TRUE

The scanned images will be saved in one multi-page file.

 

FALSE

Each scanned image will be saved in a separate file.

 

Notice that it the format doesn't support multi-page files, then each scanned page will be saved in a separate file.

uUserBufSize

Specifies a user-defined buffer size. This value will be used if uTransferMode is LTWAIN_BUFFER_MODE and the bUsePreferredBuffer parameter is FALSE. This value must be a multiple of 16.

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.

 

FALSE

Use the user-defined buffer size in the uUserBufSize parameter.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function will acquire one or more images from a TWAIN source and store the images to the specified file(s).

Based on the scanner type, this function will determine the best/fastest scanning method to use. This method will be used when actually scanning the image(s). Before calling this function you can call LTwain::FindFastConfig to determine the best scan configuration and then pass the scan configuration information to the LTwain::AcquireMulti function. If you do not call LTwain::FindFastConfig before calling LTwain::AcquireMulti, then the LTwain::AcquireMulti function will determine the best scanning method.

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", 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.

If the file format specified in nFormat supports multi-page 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 exactly the string in pszBaseFileName (Temp.jpg) and it will be saved as a multi-page file.

If uTransferMode is LTWAIN_BUFFER_MODE, and bUsePreferredBuffer is FALSE, then the function will use the user-defined buffer size in uUserBufSize. If however bUsePreferredBuffer is TRUE, then the function will use the Twain driver preferred buffer size and will ignore uUserBufSize.

To cancel the acquire operation call the LTwain::CancelAcquire.

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

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

Functions:

LTwain::AcquireCallBack, LTwain::Acquire, LTwain::AcquireList, LTwain::InitSession, LTwain::EndSession, LTwain::OpenTemplateFile, LTwain::CloseTemplateFile, LTwain::TemplateDlg, LTwain::AddCapabilityToFile, LTwain::GetNumofCapsInFile, LTwain::GetCapabilityFromFile, LTwain::FindFastConfig, LTwain::GetScanConfigs, LTwain::FreeScanConfig, LTwain::StopFeeder.

Topics:

How to Acquire from the TWAIN Source

 

TWAIN Functionality: Property Functions.

Example

class CMyTwain : public LTwain
{
public:
   L_VOID AcquireCallBack(L_INT nPage, L_TCHAR L_FAR * pszFileName, L_BOOL bFinishScan);   
};

L_VOID CMyTwain::AcquireCallBack(L_INT nPage, L_TCHAR L_FAR * 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 TestFastTwain(HWND hWnd, CMyTwain *MyClass)
{
   L_INT nRet;
   L_BOOL bAvailable;

   APPLICATIONDATA AppData;

   /* Check to see if TWAIN is installed */
   bAvailable = MyClass->IsAvailable();
   if (bAvailable)
   {
      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); 
   }
   MyClass->EnableCallBack(TRUE);
   nRet = MyClass->AcquireMulti(
                              TEXT("c:\\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;
}