LWia::AcquireToFile

#include "ltwrappr.h"

virtual L_INT LWia::AcquireToFile(uFlags, pSourceItem, pAcquireOptions, pnFilesCount, pppszFilePaths)

Acquires one or more images from a WIA source and saves them directly to file(s).

Parameters

L_UINT32 uFlags

Flag that determines certain actions of the WIA image acquisition selection dialog box. Possible values are:

Value Meaning
0 Default behavior for the device image acquisition dialog box.
L_WIA_DEVICE_DIALOG_SINGLE_IMAGE [0x00000002] Restrict image selection to a single image in the device image acquisition dialog box. This flag is not available if you are using WIA version 2.0.
L_WIA_SHOW_USER_INTERFACE [0x00000003] Show the manufacturer's image acquisition dialog box.
L_WIA_DEVICE_DIALOG_USE_COMMON_UI [0x00000004] Use the system user interface (UI), if available, rather than the vendor-supplied UI. If the system UI is not available, the vendor UI is used.

L_VOID * pSourceItem

Pointer to the scanner's paper source (either Feeder or Flatbed).

This parameter is only used if both of the following conditions are true:

WIA 1.0

If WIA 1.0 is being used, pSourceItem is optional. Three different methods can be used to specify the scanner's paper source:

WIA 2.0

If WIA 2.0 is being used, there are two different methods that can be used:

pLWIAACQUIREOPTIONS pAcquireOptions

Pointer to an optional pLWIAACQUIREOPTIONS structure that specifies how acquisition will behave. Pass NULL to use the internal default values.

L_INT * pnFilesCount

Pointer to a variable of type L_INT to be updated with the number of files saved.

L_TCHAR *** pppszFilePaths

Pointer to string buffer to hold an array of the saved file paths. Used when the transfer mode is file. To use the pppszFilePaths parameter, define a variable of type L_TCHAR** of size zero and pass the address of that variable to the acquire function.

It is the user's responsibility to free the received file name array.

Returns

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

Comments

This feature is available in LEADTOOLS version 16 or higher.

Use [LWia:AcquireToFile to acquire single or multiple images from the selected WIA device.

Make sure to call LWia::InitSession and then call any of the LWia::SelectDeviceDlg or LWia::SelectDevice functions before calling this function.

Specify the parent window for the image acquisition dialog by calling the LScanner::SetWindow function.

This function will use the file transfer mode to acquire page(s) and save them directly to the hard disk using file name specified in the szFileName member of the LWIAACQUIREOPTIONS structure. If you are acquiring more than one page with the bSaveToOneFile member of the LWIAACQUIREOPTIONS structure set to FALSE, the WIA toolkit will automatically rename the saved files by adding (N) (where N is an incremented number generated to ensure that a file with the same name exists in the same path).

Since the file transfer mode is being used, overriding the LWia::AcquireFileCallback is optional (the callback will only be providing the saved file path and the percent completion of the file save process).

To cancel the acquire operation you need to override the LWia::AcquireFileCallBack function and return ERROR_USER_ABORT error code.

Note When using the L_WIA_SHOW_USER_INTERFACE flag, be aware of the following points:

Microsoft's Image Acquisition dialog box sets its own initialization properties like the current intent (image type), selected area (left, top, width and height), paper source and duplex mode, etc.

Some of the previously set/changed user properties using any of the LWia::SetPropertyXXX or LWia::SetProperties functions will be overwritten by the Microsofts image acquisition dialog box, since this dialog sets its own initialization properties like the current intent (image type), selected area (left, top, width and height), paper source and duplex mode, etc.

So if the user wants to keep his changed properties then he should not set this flag to suppress the manufacturer's image acquisition dialog and acquire directly from the specified source item.

Note: While running a Win32 version application that calls this function while specifying the pnFilesCount and pppszFilePaths parameters on Windows VISTA 64-Bit we have noticed that these two members will not be filled back with the required information and this is a known limitation from Microsofts WIA toolkit side.

Required DLLs and Libraries

See Also

Functions

Topics

Example

class CMyWIA : public LWia 
{ 
public: 
   L_INT AcquireFileCallBack(L_TCHAR * pszFilename, L_UINT32 uPercent, L_UINT32 uFlags); 
}; 
 
L_INT CMyWIA::AcquireFileCallBack(L_TCHAR * pszFilename, L_UINT32 uPercent, L_UINT32 uFlags) 
{ 
   UNREFERENCED_PARAMETER(uPercent); 
 
   L_TCHAR szMsg[MAX_PATH] = TEXT(""); 
 
   if(uFlags & L_WIA_ACQUIRE_END_OF_PAGE && pszFilename != NULL) // at this point the file should be saved to disk. 
   { 
      wsprintf(szMsg,  
               TEXT("Acquired file saved to the following path:\n\n%s"), 
               pszFilename); 
 
      MessageBox(NULL, szMsg, TEXT("Acquire To File"), MB_OK | MB_ICONINFORMATION); 
   } 
 
   return WIA_SUCCESS; 
} 
 
L_INT LWIA__AcquireToFileExample() 
{ 
   L_INT nRet; 
   LWIAACQUIREOPTIONS AcquireOpts; 
   CMyWIA MyClass; 
 
   nRet = MyClass.InitSession(WiaVersion1); 
   if(nRet != WIA_SUCCESS) 
      return nRet; 
 
   nRet = MyClass.SelectDeviceDlg(WiaDeviceTypeDefault, 0); 
   if(nRet != WIA_SUCCESS) 
      return nRet; 
 
   /* Initialize and fill the required fields from the LWIAACQUIREOPTIONS structure */ 
   memset(&AcquireOpts, 0, sizeof(LWIAACQUIREOPTIONS)); 
   AcquireOpts.uStructSize = sizeof(LWIAACQUIREOPTIONS); 
   AcquireOpts.bAppend = FALSE; 
   AcquireOpts.bOverwriteExisting = FALSE; 
   AcquireOpts.bSaveToOneFile = FALSE; 
   lstrcpy(AcquireOpts.szFileName, MAKE_IMAGE_PATH(TEXT("Test.bmp"))); 
 
   nRet = MyClass.AcquireToFile(L_WIA_DEVICE_DIALOG_USE_COMMON_UI, 
                                &AcquireOpts,  
                                NULL, 
                                NULL, 
                                NULL); 
 
   nRet = MyClass.EndSession(); 
 
   if(nRet != WIA_SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 
Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS WIA C++ Class Library Help