LTwain::Acquire
#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 |
[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. |
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.
To stop acquire images only from the feeder of the TWAIN source, call the LTwain::StopFeeder within the LTwain::BitmapCallBack 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
Example
class CMyTwain : public LTwain
{
public:
L_INT BitmapCallBack(pBITMAPHANDLE pBitmap);
HTWAINTEMPLATEFILE m_hFile;
};
L_INT CMyTwain::BitmapCallBack(pBITMAPHANDLE pBitmap)
{
// You can do here any processing to the bitmap
return SUCCESS;
}
// initialize session and call this function
void TwainAcquire (pBITMAPHANDLE pBitmap, HWND hWnd)
{
L_INT nRet;
TW_CAPABILITY twCap;
CMyTwain MyClass;
// 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);
twCap.Cap = ICAP_XFERMECH;
twCap.ConType = TWON_ONEVALUE;
MyClass.CreateNumericContainerOneValue(&twCap, TWAINNUMERICTYPE_TW_UINT16, TWSX_NATIVE);
MyClass.SetCapability( &twCap, LTWAIN_CAPABILITY_SET);
MyClass.FreeContainer(&twCap);
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);
}