L_WiaAcquireSimple

Summary

Acquires one or more images from a WIA source.

Syntax

#include "ltwia.h"

L_LTWIA_API L_INT EXT_FUNCTION L_WiaAcquireSimple(uWiaVersion, hWndParent, uDeviceType, uFlags, pSourceItem, pAcquireOptions, pnFilesCount, pppszFilePaths, pfnCallBack, pUserData)

Parameters

L_UINT uWiaVersion

The WIA version to be used. Possible values are:

Value Meaning
WiaVersion1 [1] Use WIA version 1.
WiaVersion2 [2] Use WIA version 2.

HWND hWndParent

Handle to the window or dialog to be the parent for the device's acquiring dialog.

L_UINT32 uDeviceType

Specifies which type of WIA device to use. Possible values are:

Value Meaning
WiaDeviceTypeDefault Generic WIA device. During device enumerations, this constant is used to enumerate all WIA devices. This is the default value.
WiaDeviceTypeScanner The device is a scanner.
WiaDeviceTypeDigitalCamera The device is a camera. Note that this type of device is not supported by Windows Vista and later.
WiaDeviceTypeStreamingVideo The device contains streaming video. Note that this type of device is not supported by Windows Server 2003, Windows Vista, or later.

L_UINT32 uFlags

Flag that determines certain actions of the WIA image acquisition selection dialog box and device selection dialog. You can combine values when appropriate by using a bitwise OR ( | ). Possible values are:

Value Meaning
0 Default behavior for the device image acquisition dialog box and device selection dialog.
L_WIA_SELECT_DEVICE_NODEFAULT [0x00000001] Force displaying the Select Device dialog box even if there is only one device available.
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

This parameter is used only if you are acquiring from scanner device and the L_WIA_SHOW_USER_INTERFACE flag is NOT set. Through this parameter you can specify the scanners paper source (Feeder or Flatbed).

This flag is optional, since if you are using WIA 1.0 then you can change the paper source by changing the WIA_DPS_DOCUMENT_HANDLING_SELECT property for the root item or by enumerating the available scanner items and pass the item you wish to scan from.

If you are using WIA 2.0 then you have to enumerate the available scanner items and pass the item you wish to scan from or you can pass NULL and in this case the enumeration will be done internally and the first enumerated item will be used as the source item.

pLWIAACQUIREOPTIONS pAcquireOptions

Pointer to an optional acquires options structure that contains information the user can use to control the acquisition behavior from the WIA device.

If the user passed NULL for this parameter, internal default values will be used.

L_INT * pnFilesCount

Pointer to a variable of type L_INT to be updated with the number of the files to be saved when acquiring using File mode.

L_TCHAR *** pppszFilePaths

Pointer to string buffer to hold an array of the saved file paths. Used when the transfer mode is file.

You can 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 names array.

LWIAACQUIRECALLBACK pfnCallBack

Pointer to an optional callback the user can use to retrieve a bitmap handle that contains, in concatenated form, each transferred chunk of data. Used when the transfer mode is memory transfer.

Also this callback will provide the user with the percent completion of the acquisition process. Use this to update the progress bar.

✎ NOTE

This callback is only available when using WIA version 1.0, since the WIA 2.0 Acquire dialog does not provide a callback.

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.
< 1 An error occurred. Refer to Return Codes.

Comments

This feature is available in version 16 or higher.

This is a high level acquire function that you can call directly. When using this function, the following functions are called internally:

L_WiaInitSession

L_WiaSelectDeviceDlg

L_WiaEndSession

You can let this method do either memory transfer or file transfer by doing one of the following:

When performing memory transfer you need to provide a callback pointer to receive the acquired page(s). Use the pBitmap parameter of the callback. The callback will also provide you with the percent completion of the page transfer progress.

When performing file transfers it is optional to provide a callback pointer, since the callback will only provide the saved file path and the percent completion of the file save process.

To cancel the acquire operation provide a pointer to the LWIAACQUIRECALLBACK callback and return the ERROR_USER_ABORT error code.

✎ NOTE

If the user set the L_WIA_SHOW_USER_INTERFACE flag, then he should be aware of the following point:

Some of the previously set/changed user properties using any of the L_WiaSetPropertyXXX or L_WiaSetProperties functions will be overwritten by the Microsoft 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. This is a known limitation of Microsoft's WIA toolkit.

Required DLLs and Libraries

Platforms

LEADTOOLS WIA supports both 32-bit and 64-bit image acquisition for both WIA 1.0 (XP and earlier) and WIA 2.0 (VISTA and later).

See Also

Functions

Topics

Example

static L_INT CALLBACK WiaAcquireSimpleCB(HWIASESSION hSession, 
                                         pBITMAPHANDLE pBitmap, 
                                         L_TCHAR * pszFilename, 
                                         L_UINT32 uPercent, 
                                         L_UINT32 uFlags, 
                                         L_VOID * pUserData) 
{ 
   UNREFERENCED_PARAMETER(hSession); 
   UNREFERENCED_PARAMETER(pBitmap); 
   UNREFERENCED_PARAMETER(pszFilename); 
   UNREFERENCED_PARAMETER(uPercent); 
   UNREFERENCED_PARAMETER(uFlags); 
   UNREFERENCED_PARAMETER(pUserData); 
 
   // You can do here any processing to the bitmap. 
 
   return WIA_SUCCESS; 
} 
 
L_INT WiaAcquireSimpleExample(L_UINT uWiaVersion, HWND hWnd) 
{ 
   L_INT nRet; 
   LWIAACQUIREOPTIONS AcquireOpts; 
   L_UINT uFlags; 
 
   uFlags = L_WIA_SELECT_DEVICE_NODEFAULT | L_WIA_SHOW_USER_INTERFACE | L_WIA_DEVICE_DIALOG_USE_COMMON_UI; 
 
   /* Initialize and fill the required fields from the LWIAACQUIREOPTIONS structure */ 
   memset(&AcquireOpts, 0, sizeof(LWIAACQUIREOPTIONS)); 
   AcquireOpts.uStructSize = sizeof(LWIAACQUIREOPTIONS); 
   AcquireOpts.bDoubleBuffer = TRUE; 
   AcquireOpts.uMemBufSize = 64 * 1024; 
 
   nRet = L_WiaAcquireSimple(uWiaVersion,  
                             hWnd,  
                             WiaDeviceTypeDefault,  
                             uFlags,  
                             NULL,  
                             &AcquireOpts, 
                             NULL, 
                             NULL, 
                             WiaAcquireSimpleCB,  
                             NULL); 
   if(nRet != WIA_SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

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