Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
#include "ltwrappr.h"
virtual L_INT LTwain::Acquire (pBitmap, uStructSize, uFlags, lpszTemplateFile)
virtual L_INT LTwain::Acquire (Bitmap, uStructSize, uFlags, lpszTemplateFile)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
LBitmap * Bitmap; |
/* pointer to an LBitmap object */ |
L_UINT uStructSize; |
/* size in bytes, of the structure pointed to by pBitmap */ |
L_UINT uFlags; |
/* optional flags */ |
L_TCHAR * lpszTemplateFile; |
/* template file name */ |
Acquires one or more images from a TWAIN source.
Parameter |
Description |
|
pBitmap |
Pointer to the bitmap handle that references the last bitmap acquired from the TWAIN source. |
|
Bitmap |
Pointer to an LBitmap object that references the last bitmap acquired from the TWAIN source. |
|
uStructSize |
Size of the BITMAPHANDLE structure pointed to by pBitmap, in bytes, for versioning. Use sizeof(BITMAPHANDLE). |
|
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 |
[0x0001] Shows the manufacturer's user interface as modeless. |
|
LTWAIN_MODAL_USER_INTERFACE |
[0x0002] Shows the manufacturer's user interface as a modal dialog. Works only if the LTWAIN_SHOW_USER_INTERFACE flag is set. |
|
LTWAIN_KEEPOPEN |
[0x0020] Keep the TWAIN data source open after scanning. This flag should only be used in conjunction with LTWAIN_SHOW_USER_INTERFACE |
|
LTWAIN_MEMORY_CHECK_IMAGEINFO |
[0x0040] Check image information while scanning multi pages with different dimensions. This flag is used only with memory transfer mode. It will not affect native and file transfer modes. |
|
LTWAIN_IMAGESIZE_UNDEFINED |
[0x0080] Calculate the acquired image size after the image is acquired. This flag is used only with memory transfer mode. |
|
LTWAIN_BITMAP_TYPE_DISK |
[0x0004] Do not use conventional memory. Swap to disk only. |
lpszTemplateFile |
Character string that contains the name of the template file in which the TWAIN source capability settings will be saved. If this parameter is NULL, the TWAIN capability settings used will not be saved to a template file. For more information on determining/setting the capabilities for a TWAIN source, refer to Getting and Setting Capabilities. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
When acquiring multiple pages, the LTwain::BitmapCallBack function receives the scanned images through the pBitmap parameter. The user can then process these images as desired within the callback function.
When acquiring a single page, pass NULL for the pfnCallBack parameter. The pBitmap is updated with the single scanned image.
The number of pages to acquire can be determined by getting the TWAIN source's capabilities. To change the number of pages to acquire, set the appropriate capability to the desired number.
To cancel the acquire operation call the LTwain::CancelAcquire within the LTwain::BitmapCallBack function when it is fired.
To stop acquire images only from the feeder of the TWAIN source, call the LTwain::StopFeeder within the LTwain::BitmapCallBack function when its fired.
When scanning multi pages or multi areas with memory transfer mode, you may use LTWAIN_MEMORY_CHECK_IMAGEINFO flag to let the function check the image information for each page or area before start pending the image data to application. Some TWAIN drivers do not support image information checking, so passing this flag has no effect on the function.
The usage of the flag does not follow the TWAIN specification, but is included as work around for TWAIN drivers that scan multiple pages with different image dimensions. The usage of this flag should be limited only to these special and unusual cases.
In order to use LTWAIN_IMAGESIZE_UNDEFINED flag, you should set ICAP_XFERMECH capability to TWSX_MEMORY and then set ICAP_UNDEFINEDIMAGESIZE capability to TRUE, before calling this function, otherwise, it will return an error.
The LTWAIN_KEEPOPEN flag works only in the following cases:
1. |
Passed with LTWAIN_SHOW_USER_INTERFACE flag to make TWAIN user-interface appears as 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 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. |
See Also
Example
class CMyTwainA : public LTwain { public: L_INT BitmapCallBack(pBITMAPHANDLE pBitmap); HTWAINTEMPLATEFILE m_hFile; }; L_INT CMyTwainA::BitmapCallBack(pBITMAPHANDLE pBitmap) { UNREFERENCED_PARAMETER(pBitmap); // You can do here any processing to the bitmap return SUCCESS; } // initialize session and call this function L_INT LTwain__AcquireExample(pBITMAPHANDLE pBitmap, HWND hWnd) { UNREFERENCED_PARAMETER(hWnd); L_INT nRet; TW_CAPABILITY twCap; CMyTwainA MyClass; APPLICATIONDATA AppData; AppData.hWnd = hWnd; AppData.uStructSize = sizeof(APPLICATIONDATA); 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")); AppData.uLanguage = TWLG_ENGLISH_USA; AppData.uCountry = TWCY_USA; nRet=MyClass.InitSession(&AppData); if(nRet != SUCCESS) return nRet; // Show the Twain Select Source UI nRet = MyClass.SelectSource(NULL); if (nRet != SUCCESS) { MessageBox (NULL, TEXT("Error occurred while selecting the source."), TEXT("ERROR"), MB_OK); return nRet; } twCap.Cap = ICAP_XFERMECH; twCap.ConType = TWON_ONEVALUE; nRet = MyClass.CreateNumericContainerOneValue(&twCap, TWAINNUMERICTYPE_TW_UINT16, TWSX_NATIVE); if(nRet != SUCCESS) return nRet; nRet = MyClass.SetCapability( &twCap, LTWAIN_CAPABILITY_SET); if(nRet != SUCCESS) return nRet; nRet = MyClass.FreeContainer(&twCap); if(nRet != SUCCESS) return nRet; MyClass.EnableCallBack (TRUE); nRet = MyClass.Acquire( pBitmap, sizeof(BITMAPHANDLE), LTWAIN_SHOW_USER_INTERFACE, NULL); if (nRet == SUCCESS) MessageBox(NULL, TEXT("The image acquisition process completed."), TEXT("Notice"), MB_OK); else MessageBox(NULL, TEXT(" The image acquisition process failed!"), TEXT("Error"), MB_OK); nRet=MyClass.EndSession(); if(nRet != SUCCESS) return nRet; return nRet; }