Introduction

The LEADTOOLS TWAIN API features are available in LEADTOOLS Raster Pro, LEADTOOLS Document Imaging, LEADTOOLS Document Imaging Suite, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite toolkits. It’s functions can be used to:

manage the TWAIN sources.

acquire pages from a specified source.

handle different TWAIN sources, like scanners, barcode readers, and digital cameras.

Executable demos are included in all LEADTOOLS products. The executable demos provide a quick and easy way to evaluate features and performance.

The toolkit comes in WIN32 editions so that it can support development of software applications for any of the following environments:

Windows 4.x NT
Windows 95
Windows 98
Windows 2000

Summary of All Supported Image File Formats

Please note that due to the large size of the PDF files that contain the LEADTOOLS manuals, these files are no longer included in the setup. Instead, these PDF files can be downloaded from our website at http://support.leadtools.com/SupportPortal/DesktopDefault.aspx?tabindex=3&tabid=27.


Example Programs

The following example program is in separate EXAMPLES subdirectories (such as C:\LEAD Technologies, Inc\LEADTOOLS\Examples\DLL). The executable files for these examples were compiled with Document/Medical capabilities. To get Document/Medical capabilities, you must buy a LEADTOOLS Document/Medical edition toolkit. Otherwise, if you recompile the examples, the resulting executable files will not have the Document/Medical capabilities.

Note:

You can run the example programs on your system by clicking the appropriate buttons in online help. If you try to run an example program that is not on your system, an error message will appear.

FastTwain | Demonstrates the LEADTOOLS FAST TWAIN features in one application.
Twain Demo | Demonstrates the LEADTOOLS TWAIN features in one application.
TwnConfig | Demonstrates the LEADTOOLS TWAIN Configuration features in one application.


Version History

Current version: | 14.5
Last update: | October 19, 2005

Changes from Version 14 to Version 14.5

Changes from Version 13 to Version 14

Version 13


Changes from Version 14 to Version 14.5

Version 14.5 of LEADTOOLS TWAIN API has changed from version 14 as follows:

LEADTOOLS TWAIN API now supports JPEG compression.

LEADTOOLS TWAIN API has added high-level functions let the user get and set specific capabilities, either singularly, or in groups.

LEADTOOLS provides the ability to obtain information from the TWAIN file system, and change settings within the TWAIN file system.

The rest of this topic lists the new functions in version 14.5:

JPEG Compression Functions

L_TwainGetJPEGCompression

L_TwainSetJPEGCompression

High-Level Functions

L_TwainEnableDuplex

L_TwainGetAcquirePageOptions

L_TwainGetDuplexOptions

L_TwainGetImageBitsPerPixel

L_TwainGetImageEffects

L_TwainGetImageFrame

L_TwainGetImageUnit

L_TwainGetMaxXferCount

L_TwainGetResolution

L_TwainGetSupportedTransferMode

L_TwainGetTransferOptions

L_TwainSetAcquirePageOptions

L_TwainSetImageBitsPerPixel

L_TwainSetImageEffects

L_TwainSetImageFrame

L_TwainSetImageUnit

L_TwainSetMaxXferCount

L_TwainSetResolution

L_TwainSetRGBResponse

L_TwainSetTransferOptions

L_TwainShowProgress

Twain File System

L_TwainQueryFileSystem


Changes from Version 13 to Version 14

Version 14 of LEADTOOLS TWAIN API has changed from version 13 as follows:

LEADTOOLS TWAIN API now supports UNICODE.

Changed functions:

The following functions have been changed from the previous version of LEADTOOLS Twain API:

L_TwainAcquire (takes 1 new parameter)

The rest of this topic lists the new functions in version 14:

L_TwainCancelAcquire

L_TwainEnableShowUserInterfaceOnly

L_TwainInitSession2


Version 13

Version 13 is the first version of LEADTOOLS TWAIN API.

The rest of this topic lists the new functions in version 13.

Capability Functions

L_TwainAddCapabilityToFile

L_TwainEndCapsNeg

L_TwainEnumCapabilities

L_TwainGetCapability

L_TwainGetCapabilityFromFile

L_TwainGetNumOfCapsInFile

L_TwainSetCapability

L_TwainStartCapsNeg

Container Functions

L_TwainCreateNumericContainerArray

L_TwainCreateNumericContainerEnum

L_TwainCreateNumericContainerOneValue

L_TwainCreateNumericContainerRange

L_TwainFreeContainer

L_TwainGetNumericContainerBOOLValue

L_TwainGetNumericContainerFIX32Value

L_TwainGetNumericContainerFRAMEValue

L_TwainGetNumericContainerINTValue

L_TwainGetNumericContainerSTRINGValue

L_TwainGetNumericContainerItemType

L_TwainGetNumericContainerUINTValue

L_TwainGetNumericContainerUNICODEValue

L_TwainGetNumericContainerValue

L_TwainLockContainer

L_TwainUnlockContainer

Property Functions

L_IsTwainAvailable

L_TwainAcquire

L_TwainAcquireMulti

L_TwainAcquireList

L_TwainFindFastConfig

L_TwainFreePropQueryStructure

L_TwainFreeScanConfig

L_TwainGetProperties

L_TwainGetScanConfigs

L_TwainGetSources

L_TwainSelectSource

L_TwainSetProperties

L_TwainQueryProperty

Session Functions

L_TwainEndSession

L_TwainInitSession

Template Functions

L_TwainCloseTemplateFile

L_TwainOpenTemplateFile

L_TwainTemplateDlg

Callback Functions

LTWAINACQUIRECALLBACK

LTWAINBITMAPCALLBACK

LTWAINCAPABILITYCALLBACK

LTWAINFINDFASTCONFIG

LTWAINSAVECAPCALLBACK

LTWAINSAVEERRORCALLBACK

LTWAINSETPROPERTYCALLBACK

LTWAINSOURCECALLBACK

LTWAINSOURCEINFOCALLBACK

Extended Image Information Functions

L_TwainFreeExtendedImageInfoStructure

L_TwainGetExtendedImageInfo


Copyright notice

Copyright Notices

©Copyright LEAD Technologies, Inc. 1991-2005. ALL RIGHTS RESERVED

Portions of the PCDLIB32.DLL, PCDLIB.DLL, LFFPX7.DLL, LFKODAK.DLL, EKFPIXJPEG140.DLL, PDC_SDK.DLL, PROFIRE.DLL, DC120V154_32.DLL, LFDCR14N.DLL, DCSPROBACK.DLL, DCSPRO3SLR.DLL, LFDCS14N.DLL, and LFKDC14N.DLL files contain material that is ©Copyright Eastman Kodak Company, 1996-2001. This software is based in part on the work of the Independent JPEG Group.

Portions of the LFCRW14N.DLL, LTCMP14.DLL, CDSDK.reg, CDSDK.dll, CDRAPCLS.dll, czs_ui.dll, deimg.dll, deImg010.dll, deImg110.dll, deImg153.dll, deimg301.dll, deimg401.dll, deImg404.dll, deimg602.dll, Deimg603.dll, DeImgd60.dll, pscAdimg.dll, pscCllct.dll, pscCStUI.dll, pscDcd.dll, pscDevUI.dll, pscDvlp.dll, Pscl2STI.dll, pscll.dll, pscParse.dll, pscSetup.dll, psdkdll.dll, psdkReg.dll, psParse.dll. file contain material that is © Canon, Inc. 2002

Portions of the LFFPX7.DLL and LFKODAK.DLL files contain material that is ©Copyright Hewlett Packard, 1996.

Portions of the OCR/ICR/OMR Features and the help file for the OCR/ICR/OMR Features are ©Copyright Scansoft, Inc. 1995-2003. ALL RIGHTS RESERVED

Portions of the Barcode Modules contain material that is ©Copyright Axtel Inc., 1999.

Portions of the LEADTOOLS PDF Plug in and the LEADTOOLS Vector Imaging Pro are ©Copyright 1996, 2000 Artifex Software Inc. All rights reserved.

File filters for decoding MrSID ® and DjVu ® formats are provided under a license from Lizardtech, Inc.

The "FlashPix" format uses Microsoft's OLE structured storage.

Portions of the DICOM help files in Medical Imaging product line are reprinted with permission from the National Electrical Manufacturers Association ©Copyright 1998 by the National Electrical Manufacturers Association. All rights including translation into other languages, reserved under the Universal Copyright Convention, the Berne Convention or the Protection of Literacy and Artistic Works, and the International and Pan American Copyright Conventions.

Portions of LEADTOOLS Data Security Add On contain software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/), including cryptographic software written by Eric Young (eay@cryptsoft.com) and by Tim Hudson (tjh@cryptsoft.com). Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) All rights reserved. Copyright Tim Hudson 1995-1998 (tjh@cryptsoft.com) All rights reserved.

Portions of LEADTOOLS Data Security Add On contain software based on the MD5 Message Digest Algorithm developed by RSA Data Security, Inc.. Copyright (c) 1991-92 RSA Data Security, Inc. All Rights Reserved.

Portions hereof licensed under US patent 5,327,254 and foreign counterparts.

Portions of the LEADTOOLS ICC Profiles material is © Copyright 2004, International Color Consortium.

Trademarks

LEAD and LEADTOOLS are registered trademarks of LEAD Technologies, Inc.
Microsoft, Windows, Windows NT, Visual Basic, Visual FoxPro, and Microsoft Access are either trademarks or registered trademarks of the Microsoft Corporation.
OS/2® is a registered trademark of International Business Machines Corporation.

TextBridge®OCR is a registered trademark of Scansoft, Inc.

ISIS® is a registered trademark of Pixel Translations, Inc.

ScanAhead™ is a trademark of Pixel Translations, Inc.

FlashPix™ is a trademark of Eastman Kodak Company.

All other brand or product names used in this online help are trademarks of their respective holders.

Address and Contact Information

LEAD Technologies, Inc.
Suite 400,
1201 Greenwood Cliff,
Charlotte, NC 28204

(704) 332-5532
FAX: (704) 372-8161
Technical support: (704) 372-9681 or Support@Leadtools.com
Home page: http://www.leadtools.com


Programming with LEADTOOLS TWAIN Functions

Once the TWAIN driver is installed and configured to the system, the user is ready to begin programming with LEADTOOLS TWAIN. LEADTOOLS provides functions for:

Selecting and managing the available TWAIN source installed on the system.

Acquiring images from a selected TWAIN source.

Handling different TWAIN sources, like scanners, barcode readers, and digital cameras.

LEADTOOLS uses a TWAIN session handle to provide the means for acquiring pages from the TWAIN source. The TWAIN session handle is a communication session between LEADTOOLS TWAIN and a TWAIN driver installed on the system. This TWAIN handle is a pointer to an internal structure that contains all the necessary information for acquiring, getting and setting information, managing the TWAIN sources, and handling template files.

Getting Started

To begin using the available features in the LEADTOOLS TWAIN toolkit, the user should initialize a TWAIN session. For more information, refer to Initializing a TWAIN Session.

The user can now, select a specific TWAIN source from the sources installed on the system, or use the default TWAIN source. This must be done after the user has initialized a TWAIN session. For more information, refer to Managing the TWAIN Source.

Setting and Getting Capabilities Values

Each TWAIN source has a set of supported capabilities. The user may set these capabilities to some desired value before acquiring the image(s) or the user may elect to use the TWAIN source's default values for the capabilities. LEADTOOLS provides functions for working with capabilities in the following ways:

Enumerating the capabilities supported by the source and getting their values.

Setting or resetting defined values by the TWAIN source of a certain capability.

Getting capabilities values supported by the TWAIN source.

For more information, refer to Getting and Setting Capabilities.

Acquiring Images or Image Data

After the desired TWAIN source capabilities have been set, the user can start acquiring raster images and/or image data. Image data is related to the data acquired from a barcode, if the selected TWAIN source is the barcode reader.

For more information, refer to How to Acquire from the TWAIN Source.

The user can obtain information from the TWAIN file system, and change the settings within the TWAIN file system. For more information, refer to Getting or Setting TWAIN File System Information.

Save Settings to Files

The user can save the capability settings, used when acquiring images, in a template file. These capability settings can then obtained from the template file and used to acquire images from the same TWAIN source later, instead of getting and setting the TWAIN capabilities each time. For more information, refer to Handling Template Files.

Freeing the TWAIN Session

When the handle to the TWAIN session is no longer needed, it should be freed. For more information, refer to Freeing the TWAIN Session.


Initializing a TWAIN Session

To begin using the LEADTOOLS TWAIN toolkit, the user must initialize a Twain session handle. This is done by calling either the L_TwainInitSession function. L_TwainInitSession initializes the session without multi-threading. Each call to this function will create a session handle of type HTWAINSESSION. This handle is passed to many of the LEADTOOLS TWAIN API functions, so this function must be called before calling other LEADTOOLS TWAIN functions.

After establishing the TWAIN session handle, the user can now select the TWAIN source he or she wants to use for acquiring images. For more information on this, refer to Managing the TWAIN Source.


Managing the TWAIN Source

Once the user has established a handle to a TWAIN session, the TWAIN source to use for acquiring images should be selected. To determine the TWAIN sources available on the system, LEADTOOLS provides the L_TwainGetSources function. This function enumerates all available TWAIN sources and calls the LTWAINSOURCEINFOCALLBACK callback function for each TWAIN source found.

To select the TWAIN source to use for acquiring images, call the L_TwainSelectSource function.

Each TWAIN source has certain capabilities. The user may wish to alter these capability settings before acquiring images from the TWAIN source. For more information on this, refer to Getting and Setting Capabilities.

LEADTOOLS TWAIN toolkit also provides functions to manage the TWAIN sources installed on the system:

L_TwainSelectSource displays a dialog that lists all available TWAIN sources installed on the system. This dialog lets the user select the TWAIN source he or she wants to use.

L_TwainGetSources function is used to enumerate either all available TWAIN sources, or the currently selected TWAIN source, and retrieve the name, product family name and manufacturer name of the source(s). The LTWAINSOURCEINFOCALLBACK is called for each TWAIN source enumerated.


Getting and Setting Capabilities

Each TWAIN source may support a number of capabilities. These capabilities dictate the behavior of the TWAIN source. Before acquiring images from the selected TWAIN source, the user may wish to examine and change the capability settings for that source.

To begin this period of getting and setting the TWAIN source capabilities, the user must call L_TwainStartCapsNeg. The LEADTOOLS TWAIN toolkit provides the user low-level and high-level functionality for getting and setting the capabilities.

LEADTOOLS provides both low-level and high-level functions for getting and setting capabilities. The low-level functions get and set capabilities individually. The high-level functions let the user get and set specific capabilities, either singularly, or in groups.

Low-Level:

To get information about the capabilities supported by the selected TWAIN source, call the L_TwainEnumCapabilities function. For each capability enumerated by L_TwainEnumCapabilities, this function will call the LTWAINCAPABILITYCALLBACK callback function. Within this callback function the user can process the capability information.

To get information on a specific capability (current, default, or all possible values) call L_TwainGetCapability. This function gets information about the capability specified in a TW_CAPABILITY structure. For more information about TW_CAPABILITY, refer to the TWAIN 1.9 specification from the site "http://www.twain.org/".

To set a specific capability to a new value or to reset the value of a capability to the default value, call L_TwainSetCapability.

High-Level:

L_TwainGetProperties and L_TwainSetProperties allow the user to set and get a number of capabilities through the LTWAINPROPERTIES structure. If this structure does not have the capability needed to negotiate, the user may use the low-level functions to do so.

The L_TwainQueryProperty function lets the user get the available values for a specific capability from the selected source.

There are several transfer option capabilities that control the file name, compression, transfer mode, and file format. These can be obtained or set collectively using the L_TwainGetTransferOptions and the L_TwainSetTransferOptions functions.

In addition to the transfer options mentioned above, the transfer modes supported by the TWAIN source can be obtained by calling the L_TwainGetSupportedTransferMode function.

When transferring files from the TWAIN source there is a maximum number of files that can be transferred. To get the current value, call the L_TwainGetMaxXferCount function. To change that value, call the L_TwainSetMaxXferCount function.

There are many capabilities associated with various image characteristics, such as image resolution, image frame, image unit, bits per pixel, etc. The current values for these can be obtained using the following functions:

L_TwainGetResolution

L_TwainGetImageFrame

L_TwainGetImageUnit

L_TwainGetImageBitsPerPixel

To change the values of these capabilities, use the following functions:

L_TwainSetResolution

L_TwainSetImageFrame

L_TwainSetImageUnit

L_TwainSetImageBitsPerPixel

Image contrast, highlight and brightness capabilities can be set simultaneously by calling L_TwainSetImageEffects. To find out the current settings for contrast, highlight and brightness, call L_TwainGetImageEffects.

The RGB elements used by the TWAIN source can be set by calling the L_TwainSetRGBResponse function.

If the TWAIN source supports duplex scanning, a specific duplex mode can be enabled or disabled by calling L_TwainEnableDuplex. To get the current duplex mode and the enabled status of that mode, call L_TwainGetDuplexOptions.

The page size and orientation used during image acquisition can be set by calling L_TwainSetAcquirePageOptions. To get the current settings for these page options, call L_TwainGetAcquirePageOptions.

During the actual acquisition process, you can elect to have a progress indicator displayed. The L_TwainShowProgress function lets you hide or display the progress indicator.

After setting the desired capabilities call L_TwainAcquire to scan the pages.

When working with TW_CAPABILITY structures it may be necessary to create a container associated with that structure. For more information on containers, refer to How to Work with the Containers.

The user when dealing with the TWAIN source, can obtain or update JPEG Compression options used for TWAIN source. For more information, refer to Using JPEG Compression for a TWAIN Source.

After the user has finished enumerating, getting, setting and resetting capabilities, the L_TwainEndCapsNeg function must be called. This ends the period of getting and setting capabilities and prepares the TWAIN source for acquiring images.


How to Work with the Containers

When getting or setting capability information, it may be necessary to create a container for the associated TW_CAPABILITY structure. The structure of these containers depends on the type of information in the container. LEADTOOLS supports the following types of containers:

TW_ARRAY

TW_ENUMERATION

TW_ONEVALUE

TW_RANGE

For more information on these container types, refer to the TWAIN 1.9 Specification, available at www.twain.org.

For each type of container, LEAD provides a specific function:

L_TwainCreateNumericContainerArray, allocates the container of the TW_CAPABILITY structure to be of type TW_ARRAY and fills it with the specified data.

L_TwainCreateNumericContainerEnum, allocates the container of the TW_CAPABILITY structure to be of type TW_ENUMERATION and fills it with the specified data.

L_TwainCreateNumericContainerOneValue, allocates the container of the TW_CAPABILITY structure to be of type TW_ONEVALUE and fills it with the specified data.

L_TwainCreateNumericContainerRange, allocates the container of the TW_CAPABILITY structure to be of type TW_RANGE and fills it with the specified data.

The value in a container can be changed once the user has a pointer to the container. To change the value of a container, the user can call L_TwainLockContainer, make the desired changes to the container value(s), and then call L_TwainUnlockContainer. Alternately, the user can accomplish the same thing be calling the API GlobalLock and GlobalUnlock functions.

When the created container is no longer needed, it should be freed by calling L_TwainFreeContainer.

LEAD provides a number of functions for getting container values, based on the data type of the value. To get the data type of the value in a container, call L_TwainGetNumericContainerItemType. Once the type is known, the following functions can be used to get the container value(s) from the TW_CAPABILITY structure:

L_TwainGetNumericContainerINTValue

L_TwainGetNumericContainerUINTValue

L_TwainGetNumericContainerFIX32Value

L_TwainGetNumericContainerFRAMEValue

L_TwainGetNumericContainerSTRINGValue

L_TwainGetNumericContainerUNICODEValue

L_TwainGetNumericContainerBOOLValue

To get the available values for a specific TWAIN capability, call L_TwainQueryProperty. This function takes a pointer to a LTWAINPROPERTYQUERY structure, which will be updated with the available values for the capability.


How to Acquire from the TWAIN Source

After the user has established a TWAIN session, selected a TWAIN source, and set the desired capabilities of the TWAIN source, he or she is ready to acquire images or image data from that source. LEADTOOLS provides the following functions for acquiring images and image data from a TWAIN source:

The L_TwainAcquire function acquires one or more images from a TWAIN source. If the user has defined an LTWAINBITMAPCALLBACK function and passed a pointer to this function to L_TwainAcquire, the callback function will receive each image acquired from the source. This allows the user to process each image as desired. If only one image is acquired, and the user does not supply a callback function, the pBitmap parameter of L_TwainAcquire is updated with the acquired image. Within the LTWAINBITMAPCALLBACK function the user can call the L_TwainGetExtendedImageInfo to get extended image information that is included if the TWAIN source is a barcode reader or a digital camera. L_TwainFreeExtendedImageInfoStructure will free the TW_EXTIMAGEINFO structure that the L_TwainGetExtendedImageInfo function retrieves. For more information about TW_EXTIMAGEINFO, refer to the TWAIN 1.9 specification from the site "http://www.twain.org/".

The L_TwainAcquireList function acquires one or more images from the TWAIN source and stores them in the specified LEAD bitmap list.

The L_TwainAcquireMulti function acquires one or more images from a TWAIN source and saves the image(s) to one or more files. If the file format used does not support multi-page files, then the images will be saved to a series of files named by appending the image number to a base file name. If the file format used does support multi-page files, then the image(s) will be saved to one or more files based on the bMultiPageFile parameter. If this parameter is FALSE, then images will be saved to a series of files named by appending the image number to a base file name. If this parameter is TRUE, the image(s) will be saved to one multi-page file named using only the base file name.

The L_TwainAcquireMulti function takes an optional parameter a pointer to an LTWAINACQUIRECALLBACK callback function. This callback function is called twice for each page scanned using the L_TwainAcquireMulti function. It is called the first time when the Twain source begins scanning the page. It is called the second time when the Twain source has finished scanning the page.

To cancel a TWAIN acquisition operation, started by calling the L_TwainAcquireMulti function, call L_TwainCancelAcquire inside the LTWAINACQUIRECALLBACK callback function. To cancel a TWAIN acquisition operation, started by calling the L_TwainAcquire function, call L_TwainCancelAcquire inside the LTWAINBITMAPCALLBACK callback function.

The functions listed above can acquire images in the following transfer modes:

Native | gets the bitmaps being scanned into the memory as a whole.
Memory Buffered | gets images from the source as strips of data. These strips can be merged to get the whole image.
File | gets the images from the source to a disk file.


Handling Template Files

Template files are used to store capability information for a specific TWAIN source. That way, the next time that TWAIN source is used, the corresponding template file can provide information on the capabilities used previously.

LEADTOOLS provides the following functions for working with template files:

L_TwainTemplateDlg displays the scanning dialog provided by the manufacturer of the TWAIN source without actually acquiring the images. Instead it gets the values of all supported capabilities, which will be saved to the specified template file. Before calling this function you can determine which user interface to display by calling the L_TwainEnableShowUserInterfaceOnly function.

L_TwainOpenTemplateFile opens a template file for either reading or writing. When a template file is open for reading, the user can get capability information stored within the file. When a template file is opened for writing, capability information can be saved to that file.

L_TwainAddCapabilityToFile adds a certain capability to the file when the file is opened with write access.

L_TwainGetNumOfCapsInFile gets the number of capabilities stored in a template file.

L_TwainGetCapabilityFromFile gets the capability information by passing its index to the function.

L_TwainCloseTemplateFile closes the file and saves its contents if the file was opened with write access.

When a user acquires one or more images using the L_TwainAcquire function, the capability settings used for the TWAIN source can be saved in a template file. The next time the user wishes to use that TWAIN source he or she can open the template file saved previously, for read access, using L_TwainOpenTemplateFile. The L_TwainGetNumOfCapsInFile function will provide the number of capabilities stored in the template file. This information allows the user to loop through the stored capabilities using the L_TwainGetCapabilityFromFile function. As each capability is obtained, the user can set the capabilities for the TWAIN source using the L_TwainSetCapability function.


Fast TWAIN (Scan Configurations)

The performance of a TWAIN scanner can vary based on its scan configuration. The TWAIN driver of your TWAIN scanner comes with one or more "default" scan configurations. In addition, the user may create one or more user-defined scan configurations. LEAD provides several functions to determine the best and fastest scan configuration available, thereby letting you use the best and fastest scan configuration for scanning images.

To determine the best and fastest scan configuration for your TWAIN scanner, call L_TwainFindFastConfig. This function will test either an array of user-defined scan configurations, or all the default scan configurations present for the TWAIN driver of the current TWAIN scanner, based on the values of the pInFastConfigs and the nInFastConfigsCount parameters. For each scan configuration that is tested, the L_TwainFindFastConfig function calls the LTWAINFINDFASTCONFIG callback function. This callback function receives the information for the scan configuration being tested. This lets you interact with the scan configuration information as needed.

Since the list of default scan configurations present for a specific TWAIN driver can be rather numerous, you can narrow the list you wish to test using the L_TwainGetScanConfigs function. This function gets default scan configurations based on the transfer mode, bits per pixel and number of buffers. Therefore, you can get a list of scan configurations for a specific transfer mode, pass this list of scan configurations to the L_TwainFindFastConfig function, and decrease the number of default scan configurations that must be tested.

Both the L_TwainFindFastConfig function function and the L_TwainGetScanConfigs function allocate storage for an array of FASTCONFIG structures that contains scan configurations. This storage must be freed by calling L_TwainFreeScanConfig, when the array is no longer needed.

Once the best scan configuration has been determined, the scan configuration information can be passed to the L_TwainAcquireMulti function so the images will be acquired as fast as possible.


Freeing the TWAIN Session

When the TWAIN session handle is no longer needed, the user must free the handle by calling L_TwainEndSession. At this point the TWAIN session handle becomes invalid. Before acquiring anymore images from a TWAIN source, the user must establish a new TWAIN session handle by calling L_TwainInitSession.


Using JPEG Compression for a TWAIN Source

LEADTOOLS provides the functionality to get and set JPEG compression for a TWAIN source. Use the L_TwainGetJPEGCompression function to obtain the current TWAIN JPEG compression settings by passing LTWAIN_GET_JPEG_COMPRESSION to the uFlag parameter. Similarly, obtain the default TWAIN JPEG compression settings by passing LTWAIN_GET_DEFAULT_JPEG_COMPRESSION to the uFlag parameter when calling the L_TwainGetJPEGCompression function.

To set JPEG compression for a TWAIN source, call the L_TwainSetJPEGCompression function, and pass LTWAIN_SET_JPEG_COMPRESSION to the uFlag parameter. To restore the default TWAIN JPEG compression, call the L_TwainSetJPEGCompression function and pass LTWAIN_RESET_JPEG_COMPRESSION to the uFlag parameter.


Getting or Setting TWAIN File System Information

LEADTOOLS provides the ability to obtain information from the TWAIN file system, and change settings within the TWAIN file system using the L_TwainQueryFileSystem function.

The user can direct the TWAIN file system to perform a specific action like, change a device, domain, host, or image directory; create an image directory; delete an image or an image directory; format a storage device; rename an image or an image directory; or copy images across storage devices. The user can also direct the TWAIN file system to retrieve certain information or items such as, information on the current file, the next file in the directory, the first file in the directory, etc.

If the FileMsg parameter of L_TwainQueryFileSystem contains one of the following flags:

FILESYSTEM_MSG_CHANGEDIRECTORY

FILESYSTEM_MSG_CREATEDIRECTORY

FILESYSTEM_MSG_DELETE

FILESYSTEM_MSG_FORMATMEDIA

FILESYSTEM_MSG_RENAME

FILESYSTEM_MSG_COPY

the pTwFile parameter must contain the proper information before calling this function. This function will use the provided information to change settings within the TWAIN file system.

If the FileMsg parameter contains one of the following flags:

FILESYSTEM_MSG_GETCLOSE

FILESYSTEM_MSG_GETFIRSTFILE

FILESYSTEM_MSG_GETINFO

FILESYSTEM_MSG_GETNEXTFILE

This function, will update the pTwFile parameter with the corresponding information.

If the FileMsg parameter contains the following flag:

FILESYSTEM_MSG_AUTOMATICCAPTUREDIRECTORY

this function will use information stored within the pTwFile parameter and will update the pTwFile parameter with any appropriate information.

For example; to get information about the current file from the TWAIN file system, set the FileMsg parameter to FILESYSTEM_MSG_GETINFO and call L_TwainQueryFileSystem. The pTwFile parameter will be updated with the appropriate information.


Files To Be Included With Your Application

The installation procedure creates a directory tree for the LEADTOOLS files, and adds the demonstration programs and online help to your desktop. You specify the root directory during installation. The following subdirectory for the LEADTOOLS TWAIN features is created:

REDIST\

Redistributable LEADTOOLS TWAIN features files.

Note: | The LEADTOOLS TWAIN features are provided for evaluation purposes only. You may not copy or redistribute any of the following files without obtaining the proper license. In some cases, the license is included with your initial purchase of LEADTOOLS. In other cases, you must obtain a license from a third party or enter into a royalty agreement with LEAD to obtain the proper license. For these special licensing situations, see the notes below accompanying the specific file.
Note: | You may not distribute the header files with your application, and you may not provide software development capabilities in your application.

The following table summarizes the files you must include on your distribution diskettes to support the LEADTOOLS TWAIN features functions on a WIN32 system. (\REDIST\ subdirectory contains copies of these files.)

Please note that LTKRN is required for ALL API applications. For more information on LTKRN and other files for the Main API, refer to Files To Be Included With Your Application .

Note: All Unicode versions of LEADTOOLS require Microsoft Unicode Layer for Windows (UNICOWS.DLL) in order to function on Windows 95/98/Me. You can obtain MSUL from: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_mslu.asp.

Redistributables: | Explanation: | If you are using a standard release without Unicode, the files to use are: | If you are using a standard release with Unicode, the files to use are: | If you are using an evaluation release without Unicode, the files to use are: | If you are using an evaluation release with Unicode, the files to use are:
LTTWN | TWAIN support. LTTWN14n.DLL is the LEADTOOLS TWAIN Support DLL. | DLL: LTTWN14N.DLL Library: LTTWN_N.LIB | DLL: LTTWN14NU.DLL Library: LTTWN_NU.LIB | DLL: LTTWN14E.DLL Library: LTTWN_E.LIB | DLL: LTTWN14EU.DLL Library: LTTWN_EU.LIB


Installation Directory

The installation procedure creates a directory tree for the LEADTOOLS files, demonstration programs and online help. You specify the root directory during installation.

Please note that due to the large size of the PDF files that contain the LEADTOOLS manuals, these files are no longer included in the setup. Instead, these PDF files can be downloaded from our website at http://support.leadtools.com/SupportPortal/DesktopDefault.aspx?tabindex=3&tabid=27.

The following is a list of the subdirectories in the root directory:

BIN | Executable files for the demonstration programs.
HELP | Online help files.
EXAMPLES\DLL | One subdirectory for each example API program.
EXAMPLES\OCX | One subdirectory for each example ActiveX program.
EXAMPLES\CLASSLIB | One subdirectory for each example Class Library program.
EXAMPLES\RES | Resource files for the example programs.
INCLUDE | Header files, BAS files, and the ActiveX's MFC interface files for versions of Visual C++ earlier than 4.0.
LIB | Library files.
REDIST | Redistributable files. These are copies of the LEADTOOLS files and other files that you may need to distribute with your application. For exact information about required files, refer to Files To Be Included With Your Application.


Technical Support

As a registered user, free technical support is available. You must register your software to receive any technical support. Technical support is available 9 a.m. through 6 p.m. Eastern Standard Time. If you are calling by phone, please be at your computer. You can also contact us through the following methods:

Phone: | (704) 372-9681
E-mail: | support@leadtools.com
FAX: | (704) 372-8161
Home page: | http://www.leadtools.com
FTP: | ftp.leadtools.com

You can also contact LEAD by mail at:

LEAD Technologies, Inc.
Attn: Technical Support
Suite 400,
1201 Greenwood Cliff,
Charlotte, NC 28204

Before calling technical support, please look in the online documentation and the example programs for an answer to your question.


API Function Groups

TWAIN Functionality

Capability Functions

Container Functions

Property Functions

Session Functions

Template File Functions

Callbacks

Extended Image Information Functions

Fast TWAIN (Scan Configuration) Functions

Twain File System Functions


TWAIN Functionality: Capability Functions

TWAIN Functionality:
Capability Functions

Low Level Functions:

L_TwainAddCapabilityToFile

L_TwainEnumCapabilities

L_TwainGetCapability

L_TwainGetCapabilityFromFile

L_TwainGetNumOfCapsInFile

L_TwainSetCapability

General Functions

L_TwainEndCapsNeg

L_TwainStartCapsNeg

High Level Functions:

L_TwainEnableDuplex

L_TwainGetAcquirePageOptions

L_TwainGetDuplexOptions

L_TwainGetImageBitsPerPixel

L_TwainGetImageEffects

L_TwainGetImageFrame

L_TwainGetImageUnit

L_TwainGetMaxXferCount

L_TwainGetResolution

L_TwainGetSupportedTransferMode

L_TwainGetTransferOptions

L_TwainSetAcquirePageOptions

L_TwainSetImageBitsPerPixel

L_TwainSetImageEffects

L_TwainSetImageFrame

L_TwainSetImageUnit

L_TwainSetMaxXferCount

L_TwainSetResolution

L_TwainSetRGBResponse

L_TwainSetTransferOptions

L_TwainShowProgress


TWAIN Functionality: Container Functions

TWAIN Functionality:
Container Functions

L_TwainCreateNumericContainerArray

L_TwainCreateNumericContainerEnum

L_TwainCreateNumericContainerOneValue

L_TwainCreateNumericContainerRange

L_TwainFreeContainer

L_TwainGetNumericContainerBOOLValue

L_TwainGetNumericContainerFIX32Value

L_TwainGetNumericContainerFRAMEValue

L_TwainGetNumericContainerINTValue

L_TwainGetNumericContainerSTRINGValue

L_TwainGetNumericContainerItemType

L_TwainGetNumericContainerUINTValue

L_TwainGetNumericContainerUNICODEValue

L_TwainGetNumericContainerValue

L_TwainLockContainer

L_TwainUnlockContainer


TWAIN Functionality: Property Functions

TWAIN Functionality:
Property Functions

L_IsTwainAvailable

L_TwainAcquire

L_TwainAcquireList

L_TwainAcquireMulti

L_TwainFreePropQueryStructure

L_TwainGetJPEGCompression

L_TwainGetProperties

L_TwainGetSources

L_TwainSelectSource

L_TwainSetJPEGCompression

L_TwainSetProperties

L_TwainQueryProperty

LTWAINACQUIRECALLBACK


TWAIN Functionality: Session Functions

TWAIN Functionality:
Session Functions

L_TwainEndSession

L_TwainInitSession


TWAIN Functionality: Template File Functions

TWAIN Functionality:
Template File Functions

L_TwainCloseTemplateFile

L_TwainEnableShowUserInterfaceOnly

L_TwainOpenTemplateFile

L_TwainTemplateDlg


TWAIN Functionality: Callbacks

TWAIN Functionality:
Callbacks

LTWAINBITMAPCALLBACK

LTWAINCAPABILITYCALLBACK

LTWAINSAVECAPCALLBACK

LTWAINSAVEERRORCALLBACK

LTWAINSETPROPERTYCALLBACK

LTWAINSOURCEINFOCALLBACK

LTWAINACQUIRECALLBACK


TWAIN Functionality: Extended Image Information Functions

TWAIN Functionality:
Extended Image Information Functions

L_TwainFreeExtendedImageInfoStructure

L_TwainGetExtendedImageInfo


TWAIN Functionality: Fast TWAIN (Scan Configuration) Functions

TWAIN Functionality:
Fast TWAIN (Scan Configuration) Functions

L_TwainAcquireMulti

L_TwainFindFastConfig

L_TwainGetScanConfigs

L_TwainFreeScanConfig

LTWAINFINDFASTCONFIG


TWAIN Functionality: Twain File System Functions

TWAIN Functionality:
Twain File System Functions

L_TwainQueryFileSystem


Data Types

Basic Data Types and Keywords

LEADTOOLS Basic Data Types

Keywords Used in Declarations

TWAIN Data Types

APPLICATIONDATA

DATATRANSFER

FASTCONFIG

FILESYSTEMMSG

IMAGEEFFECTS

IMAGERESOLUTION

LTWAINNUMERICTYPE

LTWAINPROPERTIES

LTWAINPROPERTYQUERY

LTWAINSOURCE

LTWAINSOURCEINFO

HTWAINSESSION

HTWAINTEMPLATEFILE

TRANSFEROPTIONS

TWAIN_TRANSFER_MODES


Keywords Used in Declarations

LEADTOOLS uses the following keywords in declarations of functions, structures, and datatypes:

Keyword | Definition and Usage
L_FAR | Defined as nothing; used as a placeholder.
L_HUGE | Defined as nothing; used as a placeholder.
L_EXPORT | Defined as nothing; used as a placeholder.
L_PASCAL | Defined as nothing; used as a placeholder.
EXT_FUNCTION | Defined as WINAPI; used as an attribute for all toolkit functions.
pEXT_FUNCTION | Defined as EXT_FUNCTION L_FAR *; used as an attribute when defining pointers to toolkit functions.
EXT_CALLBACK | Defined as _cdecl L_FAR; used as an attribute for all toolkit callback functions.
pEXT_CALLBACK | Defined as EXT_CALLBACK L_FAR *; used as an attribute when defining pointers to toolkit callback functions.


LEADTOOLS Basic Data Types

LEADTOOLS has defined the following basic data types for portability:

Data Type | Definition and Usage
L_BITFIELD | Defined as L_UINT; used as a bit field.
L_BOOL | Defined as L_UINT; used as a boolean value.
L_CHAR | Defined as char; used as a signed 8-bit integer.
L_DOUBLE | Defined as double; used as a double precision floating point number.
L_FLOAT | Defined as float; used as a floating point number.
L_INT | Defined as int; used as a signed integer, 16-bits or larger.
L_INT16 | Defined as short; used as a signed 16-bit integer.
L_INT32 | Defined as long; used as a signed 32-bit integer.
L_UCHAR | Defined as unsigned char; used as an unsigned 8-bit integer.
L_UINT | Defined as unsigned; used as an unsigned integer, 16-bits or larger.
L_UINT16 | Defined as unsigned short; used as an unsigned 16-bit integer.
L_UINT32 | Defined as unsigned long; used as an unsigned 32-bit integer.
L_VOID | Defined as void; used as a void.
L_COMP | Defined as L_UINT; used as a handle to a computer
L_MEDIA | Defined as L_VOID L_FAR *; used as a void pointer
L_TCHAR | Defined as either char or TCHAR. If FOR_UNICODE is defined, then L_TCHAR will be defined as TCHAR.


APPLICATIONDATA

typedef struct _APPLICATIONDATA
{
HWND hWnd;
L_TCHAR zManufacturerName [256];
L_TCHAR zAppProductFamily [256];
L_TCHAR szVersionInfo [32];
L_TCHAR szAppName [256];
} APPLICATIONDATA, L_FAR * pAPPLICATIONDATA;

The APPLICATIONDATA structure provides information about an application data.

Member | Description
hWnd | Handle to the parent window to be used with the TWAIN initialization process. This must be a valid window handle (may not be set to NULL).
szManufacturerName | Character string that contains the manufacturer's name (optional).
szAppProductFamily | Character string that contains the application product family (optional).
szVersionInfo | Character string that contains the version info (optional).
szAppName | Character string that contains the application name (optional).

Comments

pAPPLICATIONDATA is a pointer to a APPLICATIONDATA structure. Where the function parameter type is pAPPLICATIONDATA, you can declare an APPLICATIONDATA variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pAPPLICATIONDATA variable is necessary only if your program requires a pointer.

APPLICATIONDATA is used with the L_TwainInitSession function.


DATATRANSFER

typedef struct _DATATRANSFER
{
L_INT nFillOrder;
L_INT nBufMemCompression;
L_INT nTransferMode;
L_INT nScanFileFormat;
L_INT nMemBufSize;
L_BOOL bSaveToOneFile;
L_BOOL bAppendToFile;
L_BOOL bDumpMemBufsToFile;
L_TCHAR szFileName [250];
} DATATRANSFER, L_FAR * pDATATRANSFER;

The DATATRANSFER structure provides information about data transferring.

Member | Description
nFillOrder | Indicates how bytes in the image are to be filled by the source. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWBO_LSBFIRST | Bytes are to be transferred with the least significant byte first.
 | TWBO_MSBFIRST | Bytes are to be transferred with the most significant byte first.
nBufMemCompression | Specifies the compression to be used when having the transfer mode set to be memory. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWCP_NONE | No compression is to be used.
 | TWCP_PACKBITS | Pack Bits compression.
 | TWCP_GROUP31D | CCITT Group 3 compression with no End of Line.
 | TWCP_GROUP31DEOL | CCITT Group 3 compression with End of Line.
 | TWCP_GROUP32D | CCITT Group 3 compression (use cap for K Factor).
 | TWCP_GROUP4 | CCITT Group 4 compression.
 | TWCP_JPEG | JPEG compression.
 | TWCP_LZW | LZW compression (like gifs).
 | TWCP_JBIG | JBIG compression, used mostly for bitonal images.
 | TWCP_PNG | PNG compressed.
 | TWCP_RLE4 | RLE4 compression.
 | TWCP_RLE8 | RLE8 compression.
 | TWCP_BITFIELDS | Bit Fields compression.
nTransferMode | Transfer mode to be used by the TWAIN source. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWSX_NATIVE | Native transfer mode.
 | TWSX_MEMORY | Memory buffered transfer mode. The source will be transferring strips of data to the application according to the buffer size given.
 | TWSX_FILE | File transfer mode. This will use a specified file to have the image data saved to. This will have a certain format specified by the properties.
nScanFileFormat | Determines the file format to use when saving the files from the TWAIN source. Possible values are (according to the TWAIN 1.9 specification) :
 | Value | Meaning
 | TWFF_TIFF | Tagged image file.
 | TWFF_PICT | Macintosh PICT.
 | TWFF_BMP | Windows regular bitmap.
 | TWFF_XBM | X-Windows bitmap.
 | TWFF_JFIF | JPEG file interchange format.
 | TWFF_FPX | Flash pix file.
 | TWFF_TIFFMULTI | Multi-page tiff file format.
 | TWFF_PNG | PNG file.
 | TWFF_SPIFF | SPIFF file.
 | TWFF_EXIF | EXIF file.
nMemBufSize | Specifies the memory buffer size to be used in data transfer.
bSaveToOneFile | Flag that indicates whether to save a multiple pages to a single file. Possible values are:
 | Value | Meaning
 | TRUE | Save to a single file.
 | FALSE | Do not save to a single file.
bAppendToFile | Flag that indicates whether to append pages to the end of the file when saving a multi-page file. Possible values are:
 | Value | Meaning
 | TRUE | Append pages to the end of the file.
 | FALSE | Do not append pages to the end of the file.
bDumpMemBufsToFile | Flag that indicates whether to use the file name specified in szFileName field to dump the memory buffers received from the scanner. In this case the Bitmap Handle will not get the Bitmap Data, all the data will be saved to the file. Possible values:
 | Value | Meaning
 | TRUE | Use file name.
 | FALSE | Do not use file name.
szFileName | Character string that contains the file name used in the file transfer mode.

Comments

pDATATRANSFER is a pointer to a DATATRANSFER structure. Where the function parameter type is pDATATRANSFER, you can declare a DATATRANSFER variable, update the structure's fields and pass the variable's address in the parameter. Declaring a pDATATRANSFER variable is necessary only if your program requires a pointer.

DATATRANSFER is used with the LTWAINPROPERTIES structure.


FASTCONFIG

typedef struct _FASTCONFIG
{
L_UINT uTransferMode;
L_INT nFileFormat;
L_UINT32 ulBufferSize;
L_UINT uTime;
L_INT nBitsPerPixel;
L_BOOL bSuccess;
} FASTCONFIG, L_FAR * pFASTCONFIG;

The FASTCONFIG structure provides information about a scan configuration to be tested or a scan configuration that is the result of testing.

Member | Description
uTransferMode | Transfer mode for the scan configuration(s). The possible values are:
 | Value | Meaning
 | LTWAIN_FILE_MODE | [0x001] Use File transfer mode
 | LTWAIN_BUFFER_MODE | [0x002] Use Memory transfer mode
 | LTWAIN_NATIVE_MODE | [0x004] Use Native transfer mode
nFileFormat | Determines the file format that will be used to save scanned images using this scan configuration.
ulBufferSize | Determines the buffer size that will be used with the buffer transfer mode. If this value is 0, then use the twain driver preferred buffer size.
uTime | The amount of time required to scan the pages used for testing the scan configuration. The number of pages depends on how many pages the user loads in the scanner when testing a scan configuration. The same pages should be used for each test.
nBitsPerPixel | Bits per pixel that will be used.
bSuccess | Specifies whether the configuration being tested succeeded. Possible values are:
 | Value | Meaning
 | TRUE | The current scan configuration was successful.
 | FALSE | The current scan configuration was not successful.

Comments

pFASTCONFIG is a pointer to a FASTCONFIG structure. Where the function parameter type is pFASTCONFIG, you can declare an FASTCONFIG variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pFASTCONFIG variable is necessary only if your program requires a pointer.

FASTCONFIG is used with the L_TwainFindFastConfig, L_TwainGetScanConfigs and L_TwainFreeScanConfig functions.


FILESYSTEMMSG

typedef enum
{
FILESYSTEMMSG_CHANGEDIRECTORY = 0x0801,
FILESYSTEMMSG_CREATEDIRECTORY = 0x0802,
FILESYSTEMMSG_DELETE = 0x0803,
FILESYSTEMMSG_FORMATMEDIA = 0x0804,
FILESYSTEMMSG_GETCLOSE = 0x0805,
FILESYSTEMMSG_GETFIRSTFILE = 0x0806,
FILESYSTEMMSG_GETINFO = 0x0807,
FILESYSTEMMSG_GETNEXTFILE = 0x0808,
FILESYSTEMMSG_RENAME = 0x0809,
FILESYSTEMMSG_COPY = 0x080A,
FILESYSTEMMSG_AUTOMATICCAPTUREDIRECTORY= 0x080B,
} FILESYSTEMMSG;

The FILESYSTEMMSG enumerated type represents the possible messages that will be used in the twain file system.

Value | Meaning
FILESYSTEMMSG_CHANGEDIRECTORY | Change the device, domain, host, or image directory.
FILESYSTEMMSG_CREATEDIRECTORY | Create an image directory.
FILESYSTEMMSG_DELETE | Delete an image or an image directory.
FILESYSTEMMSG_FORMATMEDIA | Format a storage device.
FILESYSTEMMSG_GETCLOSE | Close a file context created by FILESYSTEMMSG_GETFIRSTFILE.
FILESYSTEMMSG_GETFIRSTFILE | Get the first file in a directory.
FILESYSTEMMSG_GETINFO | Get information about the current file.
FILESYSTEMMSG_GETNEXTFILE | Get the next file in a directory.
FILESYSTEMMSG_RENAME | Rename an image or an image directory.
FILESYSTEMMSG_COPY | Copy images across storage devices.
FILESYSTEMMSG_AUTOMATICCAPTUREDIRECTORY | Place to store images acquired during automatic capture.

Comments

This enumerated type is used by the FileMsg parameter of the L_TwainQueryFileSystem to indicate which TWAIN file system settings to change or which information to retrieve.


IMAGEEFFECTS

typedef struct _IMAGEEFFECTS
{
L_INT nPixFlavor;
L_INT nColorScheme;
L_FLOAT fHighLight;
L_FLOAT fShadow;
L_FLOAT fBrightness;
L_FLOAT fContrast;
L_TCHAR szHalfTone[32];
} IMAGEEFFECTS, L_FAR * pIMAGEEFFECTS;

The IMAGEEFFECTS structure provides information about the image effects.

Member | Description
nPixFlavor | Pixel flavor used when acquiring. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWPF_CHOCOLATE | Zero stands for the darkest shade.
 | TWPF_VANILLA | Zero stands for the lightest shade.
nColorScheme | Color scheme to use when scanning is to be done. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWPT_BW | Black and White (1 bit).
 | TWPT_GRAY | 8-bit Gray Scale
 | TWPT_RGB | 24-bit RGB Color.
 | TWPT_PALETTE | 8-bit Color.
 | TWPT_CMY | CYAN, magenta, yellow color space.
 | TWPT_CMYK | CYAN, magenta, yellow, black color space.
 | TWPT_YUV | Color space type that is true color encoding. It uses one luminance value (Y) and two chroma values (UV).
 | TWPT_YUVK | The same as YUV with an additional black variable.
 | TWPT_CIEXYZ | Chromaticity diagram.
fHighLight | Highlight value.
fShadow | Shadow value.
fBrightness | Brightness value.
fContrast | Contrast value.
szHalfTone | A string having the name of the used pattern.

Comments

pIMAGEEFFECTS is a pointer to an IMAGEEFFECTS structure. Where the function parameter type is pIMAGEEFFECTS, you can declare an IMAGEEFFECTS variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pIMAGEEFFECTS variable is necessary only if your program requires a pointer.

IMAGEEFFECTS is used with the LTWAINPROPERTIES structure.


IMAGERESOLUTION

typedef struct _IMAGERESOLUTION
{
L_INT nUnitOfResolution;
L_INT nBitsPerPixel;
L_FLOAT fHorzResolution;
L_FLOAT fVertResolution;
L_FLOAT fXScaling;
L_FLOAT fYScaling;
L_FLOAT fRotationAngle;
L_FLOAT fLeftMargin;
L_FLOAT fRightMargin;
L_FLOAT fTopMargin;
L_FLOAT fBottomMargin;
} IMAGERESOLUTION, L_FAR * pIMAGERESOLUTION;

The IMAGERESOLUTION structure provides information about the images effects.

Member | Description
nUnitOfResolution | An integer having the unit of resolution to use. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWUN_INCHES | Inches unit.
 | TWUN_CENTIMETERS | Centimeters unit.
 | TWUN_PICAS | Picas unit.
 | TWUN_POINTS | Points unit.
 | TWUN_TWIPS | Twips unit.
 | TWUN_PIXELS | Pixels unit.
nBitsPerPixel | Bits per pixel the acquired images will have.
fHorzResolution | Horizontal resolution of the TWAIN source while acquiring the images.
fVertResolution | Vertical resolution of the TWAIN source while acquiring the images.
fXScaling | The acquired image X-direction scaling value before transferring.
fYScaling | The acquired image X-direction scaling value before transferring.
fRotationAngle | The acquired image rotation angle value before transfer.
fLeftMargin | The left margin of the scanning area.
fRightMargin | The right margin of the scanning area.
fTopMargin | The top margin of the scanning area.
fBottomMargin | The bottom margin of the scanning area.

Comments

pIMAGERESOLUTION is a pointer to an IMAGERESOLUTION structure. Where the function parameter type is pIMAGERESOLUTION, you can declare an IMAGERESOLUTION variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pIMAGERESOLUTION variable is necessary only if your program requires a pointer.

IMAGERESOLUTION is used with the LTWAINPROPERTIES structure.


LTWAINNUMERICTYPE

typedef enum _LTWAINNUMERICTYPE
{
TWAINNUMERICTYPE_TW_INT8 = TWTY_INT8,
TWAINNUMERICTYPE_TW_INT16 = TWTY_INT16,
TWAINNUMERICTYPE_TW_INT32 = TWTY_INT32,
TWAINNUMERICTYPE_TW_UINT8 = TWTY_UINT8,
TWAINNUMERICTYPE_TW_UINT16 = TWTY_UINT16,
TWAINNUMERICTYPE_TW_UINT32 = TWTY_UINT32,
TWAINNUMERICTYPE_TW_BOOL = TWTY_BOOL,
TWAINNUMERICTYPE_TW_FIX32 = TWTY_FIX32,
TWAINNUMERICTYPE_TW_FRAME = TWTY_FRAME,
TWAINNUMERICTYPE_TW_STR32 = TWTY_STR32,
TWAINNUMERICTYPE_TW_STR64 = TWTY_STR64,
TWAINNUMERICTYPE_TW_STR128 = TWTY_STR128,
TWAINNUMERICTYPE_TW_STR255 = TWTY_STR255,
TWAINNUMERICTYPE_TW_STR1024 = TWTY_STR1024,
TWAINNUMERICTYPE_TW_UNI512 = TWTY_UNI512
} LTWAINNUMERICTYPE;

The LTWAINNUMERICTYPE enumerates the defined types of variables.

Member | Description
TWAINNUMERICTYPE_TW_INT8 | The variable is of type L_CHAR or char.
TWAINNUMERICTYPE_TW_INT16 | The variable is of type L_INT16 or short.
TWAINNUMERICTYPE_TW_INT32 | The variable is of type L_INT32 or long.
TWAINNUMERICTYPE_TW_UINT8 | The variable is of type L_UCHAR or unsigned char.
TWAINNUMERICTYPE_TW_UINT16 | The variable is of type L_UINT16 or unsigned short.
TWAINNUMERICTYPE_TW_UINT32 | The variable is of type L_UINT32 or unsigned long.
TWAINNUMERICTYPE_TW_BOOL | The variable is of type L_BOOL or BOOL.
TWAINNUMERICTYPE_TW_FIX32 | The variable is of type TW_FIX32(TWAIN defined structure).
TWAINNUMERICTYPE_TW_FRAME | The variable is of type TW_FRAME(TWAIN defined structure).
TWAINNUMERICTYPE_TW_STR32 | The variable is of type L_CHAR[32].
TWAINNUMERICTYPE_TW_STR64 | The variable is of type L_CHAR[64].
TWAINNUMERICTYPE_TW_STR128 | The variable is of type L_CHAR[128].
TWAINNUMERICTYPE_TW_STR255 | The variable is of type L_CHAR[255].
TWAINNUMERICTYPE_TW_STR1024 | The variable is of type L_CHAR[1024].
TWAINNUMERICTYPE_TW_UNI512 | The variable is of type wchar_t[512].


LTWAINPROPERTIES

typedef struct _LTWAINPROPERTIES
{
L_BOOL bPaperSource;
L_INT nMaxNumOfPages;
L_INT nDuplexScanning;
IMAGERESOLUTION ImageRes;
DATATRANSFER DataTransfer;
IMAGEEFFECTS ImageEff;
} LTWAINPROPERTIES, L_FAR * pLTWAINPROPERTIES;

The LTWAINPROPERTIES structure provides information about the available TWAIN properties.

Member | Description
bPaperSource | Flag that indicates whether to use the Auto - Feed capability of the selected TWAIN source. Possible values are:
 | Value | Meaning
 | TRUE | Use the Auto - Feed capability.
 | FALSE | Do not use the Auto - Feed capability.
nMaxNumOfPages | The maximum number of pages to get from the TWAIN source. (If the function updates this field to -1, it means that the number of pages is unlimited.)
nDuplexScanning | (Read only) Gets the type of duplex scanning. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWDX_NONE | No duplex used.
 | TWDX_1PASSDUPLEX | 1 pass duplex.
 | TWDX_2PASSDUPLEX | 2 pass duplex.
ImageRes | A structure of type IMAGERESOLUTION that contains image resolution data for the TWAIN source.
DataTransfer | A structure of type DATATRANSFER that contains data transfer information for the TWAIN source.
ImageEff | A structure of type IMAGEEFFECTS that contains image effects information for the TWAIN source.

Comments

pLTWAINPROPERTIES is a pointer to an LTWAINPROPERTIES structure. Where the function parameter type is pLTWAINPROPERTIES, you can declare an LTWAINPROPERTIES variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pLTWAINPROPERTIES variable is necessary only if your program requires a pointer.

LTWAINPROPERTIES is used with the L_TwainGetProperties and L_TwainSetProperties functions.


LTWAINPROPERTYQUERY

typedef struct _LTWAINPROPERTYQUERY
{
L_UINT uType;
union
{
pTW_ONEVALUE pltwOneValue;
pTW_RANGE pltwRange;
pTW_ENUMERATION pltwEnumeration;
pTW_ARRAY pltwArray;
};
} LTWAINPROPERTYQUERY, L_FAR * pLTWAINPROPERTYQUERY;

The LTWAINPROPERTYQUERY structure provides information about the capability properties.

Member | Description
uType | Holds the type of pointer to use from the union. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWON_ONEVALUE | The container is of type TW_ONEVALUE and only the pltwOneValue pointer is used.
 | TWON_RANGE | The container is of type TW_RANGE and only the pltwRange pointer is used.
 | TWON_ONEVALUE | The container is of type TW_ENUMERATION and only the pltwEnumeration pointer is used.
 | TWON_ONEVALUE | The container is of type TW_ARRAY and only the pltwArray pointer is used.
pltwOneValue | Pointer to a TW_ONEVALUE structure.
pltwRange | Pointer to a TW_RANGE structure.
pltwEnumeration | Pointer to a TW_ENUMERATION structure.
pltwArray | Pointer to a TW_ARRAY structure.

Comments

pLTWAINPROPERTYQUERY is a pointer to an LTWAINPROPERTYQUERY structure. Where the function parameter type is pLTWAINPROPERTYQUERY, you can declare an LTWAINPROPERTYQUERY variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pLTWAINPROPERTYQUERY variable is necessary only if your program requires a pointer.

LTWAINPROPERTIES is allocated by the L_TwainQueryProperty function and freed by L_TwainFreePropQueryStructure function.


LTWAINSOURCE

typedef struct _LTWAINSOURCE
{
L_TCHAR * pszTwainSourceName;
} LTWAINSOURCE, L_FAR * pLTWAINSOURCE;

The LTWAINSOURCE structure provides information about the available TWAIN source.

Member | Description
pszTwainSourceName | Character string that contains the name of the required TWAIN source.

Comments

pLTWAINSOURCE is a pointer to an LTWAINSOURCE structure. Where the function parameter type is pLTWAINSOURCE, you can declare an LTWAINSOURCE variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pLTWAINSOURCE variable is necessary only if your program requires a pointer.

LTWAINSOURCE is used with the L_TwainSelectSource function.


LTWAINSOURCEINFO

typedef struct _LTWAINSOURCEINFO
{
L_TCHAR * pszTwnSourceName;
L_TCHAR * pszTwnProductFamily;
L_TCHAR * pszTwnManufacturer;
} LTWAINSOURCEINFO, L_FAR * pLTWAINSOURCEINFO;

The LTWAINSOURCEINFO structure provides information about the available TWAIN source.

Member | Description
pszTwainSourceName | Character string that contains the name of the TWAIN source.
PszTwnProductFamily | Character string that contains the scanner product family name.
pszTwnManufacturer | Character string that contains the manufacturer name of the scanner.

Comments

pLTWAINSOURCEINFO is a pointer to an LTWAINSOURCEINFO structure. Where the function parameter type is pLTWAINSOURCEINFO, you can declare an LTWAINSOURCEINFO variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pLTWAINSOURCEINFO variable is necessary only if your program requires a pointer.

LTWAINSOURCEINFO is used with the LTWAINSOURCEINFOCALLBACK function.


HTWAINSESSION

LEADTOOLS has defined the following data types for referencing TWAIN session:

Data Type | Definition and Usage
HTWAINSESSION | Defined as HANDLE; used as a handle of a TWAIN session.
pHTWAINSESSION | Defined as HTWAINSESSION *; used as a pointer to a TWAIN session handle.


HTWAINTEMPLATEFILE

LEADTOOLS has defined the following data types for referencing TWAIN template file:

Data Type | Definition and Usage
HTWAINTEMPLATEFILE | Defined as HANDLE; used as a handle of a TWAIN template file.
pHTWAINTEMPLATEFILE | Defined as HTWAINTEMPLATEFILE *; used as a pointer to a TWAIN template file handle.


TWAIN_TRANSFER_MODES

typedef enum
{
TWAIN_TRANSFER_FILE = 0x001,
TWAIN_TRANSFER_MEMORY = 0x002,
TWAIN_TRANSFER_NATIVE = 0x004,
} TWAIN_TRANSFER_MODES;

Determines the transfer mode.

Value | Meaning
TWAIN_TRANSFER_FILE | [0x001] Specifies the file transfer mode.
TWAIN_TRANSFER_MEMORY | [0x002] Specifies the memory transfer mode.
TWAIN_TRANSFER_NATIVE | [0x004] Specifies the native transfer mode.


TRANSFEROPTIONS

typedef struct _tagTransferOptions
{
L_UINT uStructSize;
TWAIN_TRANSFER_MODES TransferMode;
L_TCHAR szFileName[L_MAX_PATH];
L_UINT uFileFormat;
L_UINT uCompType;
} TRANSFEROPTIONS, L_FAR * pTRANSFEROPTIONS;

The TRANSFEROPTIONS structure provides information about transfer options to be used in acquire process.

Member | Description
uStructSize | Size of this structure in bytes, for versioning. Use the sizeof() macro to calculate this value.
TransferMode | Specifies the transfer mode. For possible values, refer to the TWAIN_TRANSFER_MODES enumeration.
szFileName | Character string that contains the file name to transfer if the TransferMode is set to TWAIN_TRANSFER_FILE flag.
uFileFormat | The file format to transfer if the TransferMode is set to TWAIN_TRANSFER_FILE flag. For more information about the supported file formats, refer to the Formats of Input Files .
uCompType | The compression type to be used if the TransferMode is set to TWAIN_TRANSFER_MEMORY flag.

Comments

pTRANSFEROPTIONS is a pointer to a TRANSFEROPTIONS structure. Where the function parameter type is pTRANSFEROPTIONS, you can declare a TRANSFEROPTIONS variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pTRANSFEROPTIONS variable is necessary only if your program requires a pointer.

TRANSFEROPTIONS is used with the L_TwainSetTransferOptions and L_TwainGetTransferOptions functions.


Return Codes

For a list of all possible return codes for LEADTOOLS Twain API functions, refer to LEADTOOLS API Return Codes in the Main API help file.


Tutorials

Take the following steps to create and run a program that implements LEADTOOLS TWAIN features. Remember, the purpose of the TWAIN tutorial is to provide you a quick and easy way to generate a TWAIN program. For more in depth TWAIN programming, refer to the TWAIN demo.

1. | Create a new directory in the LTWINxxx\EXAMPLES\DLL directory called EZTWN.
2. | Copy everything in the EZFUNC directory into the EZTWN directory.
3. | Rename the EZFunc.c file to be EZFunc.cpp.
4. | Remove the EXFunc.c from the project and add the EZFunc.cpp in its place.
5. | Compile the project as it is and run EZFUNC32.exe to familiarize yourself with the basic program. You can run the exe file from the MS-DOS prompt, or set the image file to load through the Project->Settings->Debug->Program Arguments menu.
6. | On the Insert menu, select Files into Project. Add the Lttwn_n.lib file to the project from the LTWINxxx\LIB directory.
7. | Define the following global variables in EZFUNC.CPP in the EZTWN directory:

BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */
HTWAINSESSION hSession = NULL;

8. | In the project workspace go to the resources tab. Add a menu ("MAIN_MENU") to the application with the following menu items:
 | ID | Caption
 | IDM_SELECT_SOURCE | Select Source
 | IDM_ACQUIRE | Acquire
 | IDM_NATIVE_TRANSFER | Native Transfer
 | IDM_MEMORY_TRANSFER | Memory Transfer
 | IDM_FILE_TRANSFER | File Transfer
9. | In the InitApplication function change the line:

wcWindowClass.lpszMenuName = NULL; /* No menu */
to be
wcWindowClass.lpszMenuName = TEXT("MAIN_MENU");

10.

In the EZFunc.cpp add the following includes:

#include "resource.h"
#include "LTWINxxx\Include\ltTwain.h"

11.

In the MainWndProc function and before the handling of the WM_PALETTECHANGED message add the following code:

case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDM_SELECT_SOURCE:
{
}
break;
case IDM_ACQUIRE:
{
}
break;
case IDM_NATIVE_TRANSFER:
{
}
break;
case IDM_MEMORY_TRANSFER:
{
}
break;
case IDM_FILE_TRANSFER:
{
}
break;
}
}
break;

12.

In the WM_CREATE message handler add the following code at the end of it (after SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L);):

APPLICATIONDATA AppData;
AppData.uStructSize = sizeof(APPLICATIONDATA);
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, TXT("TWAIN Test Application"));
nRet = L_TwainInitSession(&hSession, &AppData);
if (nRet != SUCCESS)
return FALSE;
nRet = L_TwainStartCapsNeg(hSession);

13.

In the WM_DESTROY message handler add the following code at the end of it (before the PostQuitMessage (0);):

L_TwainEndCapsNeg(hSession);
L_TwainEndSession(&hSession);

14.

In the IDM_SELECT_SOURCE menu handler add the following code:

case IDM_SELECT_SOURCE:
{
nRet = L_TwainSelectSource(hSession, NULL);
}
break;

15.

In the IDM_ACQUIRE menu handler add the following code:

case IDM_ACQUIRE:
{
if (LeadBitmap.Flags.Allocated)
L_FreeBitmap
 (&LeadBitmap);
L_TwainEndCapsNeg(hSession);
nRet = L_TwainAcquire(hSession, &LeadBitmap, sizeof(BITMAPHANDLE), NULL, LTWAIN_SHOW_USER_INTERFACE, NULL, NULL);
if (nRet != SUCCESS)
return nRet;
L_TwainStartCapsNeg(hSession);
InvalidateRect (hWnd, NULL, FALSE);
}
break;

16.

In IDM_NATIVE_TRANSFER menu handler add the following code:

LTWAINPROPERTIES twProps;
memset (&twProps, 0, LTWAINPROPERTIESSIZE);
nRet = L_TwainGetProperties(hSession, &twProps, LTWAIN_PROPERTIES_GETCURRENT);
if (nRet != SUCCESS)
return nRet;
twProps.DataTransfer.nTransferMode = TWSX_NATIVE;
nRet = L_TwainSetProperties(hSession, &twProps, LTWAIN_PROPERTIES_SET, NULL, NULL);
if (nRet != SUCCESS)
return nRet;

17.

In the IDM_MEMORY_TRANSFER menu handler add the following code:

LTWAINPROPERTIES twProps;
memset (&twProps, 0, LTWAINPROPERTIESSIZE);
nRet = L_TwainGetProperties(hSession, &twProps, LTWAIN_PROPERTIES_GETCURRENT);
if (nRet != SUCCESS)
return nRet;
twProps.DataTransfer.nTransferMode = TWSX_MEMORY;
twProps.DataTransfer.nBufMemCompression = TWCP_NONE;
nRet = L_TwainSetProperties(hSession, &twProps, LTWAIN_PROPERTIES_SET, NULL, NULL);
if (nRet != SUCCESS)
return nRet;

18.

In the IDM_FILE_TRANSFER menu handler add the following code:

LTWAINPROPERTIES twProps;
memset (&twProps, 0, LTWAINPROPERTIESSIZE);
nRet = L_TwainGetProperties(hSession, &twProps, LTWAIN_PROPERTIES_GETCURRENT);
if (nRet != SUCCESS)
return nRet;
twProps.DataTransfer.nTransferMode = TWSX_NATIVE;
lstrcpy (twProps.DataTransfer.szFileName, TEXT("c:\\twain.bmp"));
nRet = L_TwainSetProperties(hSession, &twProps, LTWAIN_PROPERTIES_SET, NULL, NULL);
if (nRet != SUCCESS)
return nRet;

19.

Compile and test the program.


Using the Fast TWAIN Features

Take the following steps to start a project and to add some code that acquires the images using the LEADTOOLS Fast TWAIN features:

1. | Start a new project as follows:
 | Run Microsoft Visual C++ 5.0, select the File -> New menu option, and do the following:
 | a. | Click the Projects tab.
 | b. | Select MFC AppWizard (exe) as the project type.
 | c. | In the Project name text box, specify tutor.
 | d. | In the Location text box, specify the path of the project.
 | e | Click the OK button.
2. | In the Step 1 dialog box, do the following:
 | a. | Select Dialog based.
 | b. | Click the Next button.
3. | In the Step 2 of 4 dialog box, do the following:
 | a. | Ensure that About Box is selected.
 | b. | Ensure that 3D Controls is selected.
 | c. | Select ActiveX Controls.
 | d. | Click the Next button.
4. | In the Step 3 of 4 dialog box, do the following:
 | a. | For comments, ensure that Yes, Please is selected.
 | b. | For how to use the MFC library, select Use MFC in a Shared DLL.
 | c. | Click the Next button.
5. | In the Step 4 of 4 dialog box, just click Finish.
6. | Read New Project Information, and click OK. (The AppWizard creates the project files and opens the project.)
7. | Add #include statements to your program so you can access the LEAD Twain DLL functions:
 | a. | In the Project Workspace, click the FileView tab.
 | b. | Double-click the tutor files folder to open it.
 | c. | Double-click the Header Files folder to open it.
 | d. | Double-click the StdAfx.h file to edit it.
 | Add the following lines to the end of the file (keep in mind, you may have to change the path to where the dll's reside):

#include "..\..\..\include\l_bitmap.h"
#include "..\..\..\include\lttw2.h"

8. | Add the LEAD Twain LIB file to your program:
 | a. | In the Project menu, select Add to Project-> Files menu.
 | b. | Go to the path that contains the lttw2_n.lib.
 | c. | Select the lttw2_n.lib and press OK.
9. | Add a HTWAINSESSION member to the class and set it to NULL in the constructor.
 | a. | In the Project Workspace, click the Class View tab.
 | b. | Select the CTutorDlg class.
 | c. | Right-click and choose "Add Member Variable".
 | d. | For Variable Type enter HTWAINSESSION.
 | e. | For Variable Declaration enter m_hSession.
 | f. | Leave Access as Public.
 | g. | Click the OK button.
 | h. | In the Class View tab, double-click the CTutorDlg constructor function.
 | i. | Add the following line to the end of the constructor:

m_hSession = NULL;

10. | Go to the Project WorkSpace and click the Resource View tab. Double-click Dialog and double-click IDD_TUTOR_DIALOG to bring up the application's dialog box.
11. | Add 1 check box. To do this, select the check box control on the Controls toolbar. Then, click and drag to position the button on the dialog box. Then double-click the check box to change its properties. Set the properties as follows:
 | ID | Caption
 | IDC_USEBUFFERSIZE | Use Buffer Size
12. | Add two Radio buttons in addition to the above buttons.
 | ID | Caption
 | IDC_NATIVE | Native Mode
 | IDC_MEMORY | Memory Mode
13. | Add the following button:
 | ID | Caption
 | IDC_ACQUIRE | Fast Acquire
14. | Add the following two text boxes and name them as follows:
 | ID
 | IDC_BUFFERSIZE
 | IDC_FILENAME
15. | Add the following code to the end of OnInitDialog before the return statement:

APPLICATIONDATA AppData;
AppData.uStructSize = sizeof(APPLICATIONDATA);
AppData.hWnd = GetSafeHwnd(); // Window handle of an application, may not be NULL
lstrcpy (AppData.szManufacturerName, TEXT("LEAD Technologies, Inc.")); // Application manufacturer name
lstrcpy (AppData.szAppProductFamily, TEXT("LEAD Test Applications")); // Application product family
lstrcpy (AppData.szVersionInfo, TEXT("Version 14.0")); // Application version info
lstrcpy (AppData.szAppName, TEXT("TWAIN Utility Application")); // Application Name

// initialize the twain session to use other lead twain functions
L_INT nRet = L_TwainInitSession (&m_hSession, &AppData);
if (nRet != SUCCESS)
return FALSE;

16. | To end the Twain session and free memory allocated by the Twain DLL, add the following code in the destructor of the CTutorDlg. To do so, press Ctrl-W to go to the MFC Class Wizard; then do the following:
 | a. | In the Class name combo box, select CTutorDlg.
 | b. | In the Object IDs list box, select CTutorDlg.
 | c. | In the Messages list box, select WM_DESTROY.
 | d. | Click the Add Function button. Choose OK for the default function name (OnDestroy).
 | e. | Click the Edit Code button to enter the following code before CDialog::OnDestroy();

if (m_hSession)
L_TwainEndSession (&m_hSession);

17. | Add the following member variables for the following controls. To do so, press Ctrl-W to go to the MFC Class Wizard; then do the following:
 | a. | Select Member variables tab.
 | b. | In the Class name combo box, select CTutorDlg.
 | c. | Select each of the following controls and add the corresponding member variable by pressing the Add variable button.

ID | Member variable | Type
IDC_USEBUFFERSIZE | m_bUseBufferSize | BOOL
IDC_BUFFERSIZE | m_nBufferSize | Int
IDC_FILENAME | m_csFileName | Cstring

 | d. | Press Ok.
18. | Add code for the select source button (IDC_ACQUIRE). To do so, press Ctrl-W to go to the MFC Class Wizard; then do the following:
 | a. | Click the Message Maps tab.
 | b. | In the Class Name combo box, select CTutorDlg.
 | c. | In the Object IDs list box, select IDC_ACQUIRE.
 | d. | In the Messages list box, select BN_CLICKED.
 | e. | Click the Add Function button. Choose OK for the default function name (OnAcquire).
 | f. | Click the Edit Code button to start entering the code.

void CTutorDlg::OnAcquire()
{
UpdateData();

L_INT nFormat;
L_UINT uTransferMode;

BOOL bMemory = IsDlgButtonChecked(IDC_MEMORY);
if (bMemory)
{
uTransferMode = LTWAIN_BUFFER_MODE;
nFormat = FILE_CCITT_GROUP4;
}
else
{
uTransferMode = LTWAIN_NATIVE_MODE;
nFormat = FILE_TIF;
}

L_INT nRet = L_TwainAcquireMulti (m_hSession,
(L_TCHAR L_FAR *)(LPCTSTR)m_csFileName,
LTWAIN_SHOW_USER_INTERFACE | LTWAIN_USE_THREAD_MODE,
uTransferMode,
nFormat,
1,
TRUE,
m_nBufferSize,
!m_bUseBufferSize);

if (nRet == 0)
AfxMessageBox(TEXT("Fast Scanning process done successfully..."));
else
{
CString csError;
csError.Format(TEXT("AcquireMulti failed, Error = %d\n"), nRet);
AfxMessageBox(csError);
}
}

19.

Compile and run your program to test it.


Get a Fast Twain Scan from a Scanner

Take the following steps to get fast twain scan using the LEADTOOLS Fast TWAIN features:

1. | Create a new directory in the LTWINxxx\EXAMPLES\DLL directory called EZTWN2.
2. | Copy everything in the EZFUNC directory into the EZTWN2 directory.
3. | Rename the EZFunc.c file to be EZFunc.cpp.
4. | Remove the EXFunc.cpp from the project and add the EZFunc.cpp in its place.
5. | Compile the project as it is and run EZFUNC32.exe to familiarize yourself with the basic program. You can run the exe file from the MS-DOS prompt, or set the image file to load through the Project->Settings->Debug->Program Arguments menu.
6. | On the Insert menu, select Files into Project. Add the lttw2_n.lib file to the project from the LTWINxxx\LIB directory.
7. | Define the following global variables in EZFUNC.CPP in the EZTWN directory:

HTWAINSESSION hSession = NULL;
FASTCONFIG BestConfig;

8. | In the project workspace go to the resources tab. Add a menu ("MAIN_MENU") to the application with the following menu items:
 | ID | Caption
 | IDM_SELECT_SOURCE | Select Source
 | IDM_FIND_FAST_CONFIG | Find Fast Config
 | IDM_ACQUIRE_FAST_CONFIG | Acquire Fast Config
9. | In the InitApplication function change the line:

wcWindowClass.lpszMenuName = NULL; /* No menu */

to be

wcWindowClass.lpszMenuName = TEXT("MAIN_MENU");

10.

In the EZFunc.cpp add the following includes:

#include "resource.h"
#include "LTWINxxx\Include\ltTw2.h"

11.

In the MainWndProc function and before the handling of the WM_PALETTECHANGED message add the following code:

case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDM_SELECT_SOURCE:
{
}
break;
case IDM_FIND_FAST_CONFIG:
{
}
break;
case IDM_ACQUIRE_FAST_CONFIG:
{
}
break;
}
}
break;

12.

In the WM_CREATE message handler add the following code at the end of it (after SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L);):

APPLICATIONDATA AppData;
AppData.uStructSize = sizeof(APPLICATIONDATA);
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 = L_TwainInitSession(&hSession, &AppData);
if (nRet != SUCCESS)
return FALSE;

/* Unlock Document support.
Note that this is a sample key, which will not work in your toolkit. */
L_UnlockSupport (L_SUPPORT_DOCUMENT, TEXT("TestKey"));

13.

In the WM_DESTROY message handler add the following code at the end of it (before the PostQuitMessage (0);):

L_TwainEndSession(&hSession);

14.

In the IDM_SELECT_SOURCE menu handler add the following code:

case IDM_SELECT_SOURCE:
{
nRet = L_TwainSelectSource(hSession, NULL);
}
break;

15.

In the IDM_FIND_FAST_CONFIG menu handler add the following code:

case IDM_FIND_FAST_CONFIG:
{
pFASTCONFIG pTestConfigs = NULL;
L_INT nTestConfigsCount = 0;

nRet = L_TwainFindFastConfig(hSession,
TEXT("c:\\temp"),
LTWAIN_SHOW_USER_INTERFACE | LTWAIN_USE_THREAD_MODE,
8, 5, NULL, 0,
&pTestConfigs,
&nTestConfigsCount,
&BestConfig,
sizeof(FASTCONFIG),
NULL,
NULL);
if (nRet == SUCCESS)
MessageBox(hWnd, TEXT("Find Fast Configuration process completed"), TEXT("Fast Config"), MB_OK);
else
MessageBox(hWnd, TEXT("An error occurred during the Finding Fast Configuration process."), TEXT("Fast Config"), MB_OK);
}
break;

16.

In the IDM_ACQUIRE_FAST_CONFIG menu handler add the following code:

case ID case IDM_ACQUIRE_FAST_CONFIG:
{
nRet = L_TwainAcquireMulti(hSession,
TEXT("c:\\temp\\testconfig.tif"),
LTWAIN_SHOW_USER_INTERFACE | LTWAIN_USE_THREAD_MODE,
BestConfig.uTransferMode,
BestConfig.nFileFormat,
BestConfig.nBitsPerPixel,
TRUE,
BestConfig.ulBufferSize,
TRUE,
NULL,
NULL);
if (nRet == SUCCESS)
MessageBox(hWnd, TEXT("Image acquisition using the Fast TWAIN Configuration is completed."), TEXT("Fast Config"), MB_OK);
else
MessageBox(hWnd, TEXT("An error occurred while acquiring images using the Fast TWAIN Configuration."), TEXT("Fast Config"), MB_OK);
}
break;

17.

Add the following definition in the top of the EZFunc.cpp file, and before any include statement:

#define USE_NEWTWAIN

18.

Compile and test the program.


Set/Get a Twain Capability

Take the following steps to get or set a twain capability:

1. | Create a new directory in the LTWINxxx\EXAMPLES\DLL directory called EZTWNCAP.
2. | Copy everything in the EZFUNC directory into the EZTWNCAP directory.
3. | Rename the EZFunc.c file to be EZFunc.cpp.
4. | Remove the EXFunc.cpp from the project and add the EZFunc.cpp in its place.
5. | Compile the project as it is and run EZFUNC32.exe to familiarize yourself with the basic program. You can run the exe file from the MS-DOS prompt, or set the image file to load through the Project->Settings->Debug->Program Arguments menu.
6. | On the Insert menu, select Files into Project. Add the lttw2_n.lib file to the project from the LTWINxxx\LIB directory.
7. | Define the following global variables in EZFUNC.CPP in the EZTWNCAP directory:

HTWAINSESSION hSession = NULL;
TW_CAPABILITY twCap;
L_UINT uItemValue;

8.

Add the following definition in the top of the EZFunc.cpp file, before any include statement:

#define USE_NEWTWAIN

9. | In the project workspace go to the resources tab. Add a menu ("MAIN_MENU") to the application with the following menu items:
 | ID | Caption
 | IDM_SELECT_SOURCE | Select Source
 | IDM_GET_CAPABILITY | Get Capability
 | IDM_SET_CAPABILITY | Set Capability
 | IDM_SET_BRIGHTNESS | Set Brightness
 | IDM_ACQUIRE | Acquire
10. | In the InitApplication function change the line:

wcWindowClass.lpszMenuName = NULL; /* No menu */

to be

wcWindowClass.lpszMenuName = TEXT("MAIN_MENU");

11.

In the EZFunc.cpp file add the following includes:

#include "resource.h"
#include "LTWINxxx\Include\ltTw2.h"

12.

In the MainWndProc function, before the handling of the WM_PALETTECHANGED message, add the following code:

case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDM_SELECT_SOURCE:
{
}
break;
case IDM_GET_CAPABILITY:
{
}
break;
case IDM_SET_CAPABILITY:
{
}
break;
case IDM_SET_BRIGHTNESS:
{
}
break;
case IDM_ACQUIRE:
{
}
break;
}
}
break;

13.

In the WM_CREATE message handler add the following code at the end of it (after SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L);):

APPLICATIONDATA AppData;
AppData.uStructSize = sizeof(APPLICATIONDATA);
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 = L_TwainInitSession(&hSession, &AppData);
if (nRet != SUCCESS)
return FALSE;

/* Unlock Document support.
Note that this is a sample key, which will not work in your toolkit. */
L_UnlockSupport (L_SUPPORT_DOCUMENT, TEXT("TestKey"));

14.

In the WM_DESTROY message handler add the following code at the end of it (before the PostQuitMessage (0);):

L_TwainEndCapsNeg(hSession);
L_TwainEndSession(&hSession);

15.

In the IDM_SELECT_SOURCE menu handler add the following code:

case IDM_SELECT_SOURCE:
{
nRet = L_TwainSelectSource(hSession, NULL);
}
break;

16.

In the IDM_GET_CAPABILITY menu handler add the following code:

case IDM_GET_CAPABILITY:
{
L_INT nItemType;

twCap.Cap = ICAP_XFERMECH;
twCap.ConType = TWON_DONTCARE16;
twCap.hContainer = NULL;
L_TwainGetCapability(hSession, &twCap, LTWAIN_CAPABILITY_GETCURRENT);

L_TwainGetNumericContainerItemType(&twCap, &nItemType);

if (nItemType == TWTY_UINT16)
L_TwainGetNumericContainerUINTValue(&twCap, 0, &uItemValue);
else
MessageBox(hWnd, TEXT("Returned bad item type"), TEXT("Get Item Type"), MB_OK);
}
break;

17.

In the IDM_SET_CAPABILITY menu handle add the following code:

case IDM_SET_CAPABILITY:
{
if (uItemValue != TWSX_NATIVE)
{
TW_CAPABILITY twSetCap;

twSetCap.Cap = ICAP_XFERMECH;
twSetCap.ConType = TWON_ONEVALUE;

L_TwainCreateNumericContainerOneValue(&twSetCap, TWAINNUMERICTYPE_TW_UINT16, TWSX_NATIVE);

L_TwainSetCapability(hSession, &twSetCap, LTWAIN_CAPABILITY_SET);
L_TwainFreeContainer(&twSetCap);
}
else
MessageBox(hWnd, TEXT("The Transfer mode is Native"), TEXT("Set Capability"), MB_OK);
}
break;

18.

In the IDM_SET_BRIGHTNESS menu handle add the following code:

case IDM_SET_BRIGHTNESS:
{
TW_CAPABILITY twBrightnessCap;
TW_FIX32 twFix32;
pTW_ONEVALUE ptwOneVal;

twBrightnessCap.Cap = ICAP_BRIGHTNESS;
twBrightnessCap.ConType = TWON_ONEVALUE;

L_INT nRet = L_TwainGetCapability (hSession, &twBrightnessCap, LTWAIN_CAPABILITY_GETCURRENT);

ptwOneVal = (pTW_ONEVALUE)GlobalLock(twCap.hContainer);

memcpy(&twFix32, (void *)&ptwOneVal->Item, sizeof(TW_FIX32));

GlobalUnlock(twBrightnessCap.hContainer);
GlobalFree(twBrightnessCap.hContainer);
twBrightnessCap.hContainer = NULL;

if (twFix32.Whole != 128)
{
twFix32.Whole = 128;
twFix32.Frac = 0;
}

twBrightnessCap.Cap = ICAP_BRIGHTNESS;
twBrightnessCap.ConType = TWON_ONEVALUE;
twBrightnessCap.hContainer = GlobalAlloc(GHND, sizeof(TW_ONEVALUE) + sizeof(TW_FIX32));

ptwOneVal = (pTW_ONEVALUE)GlobalLock(twCap.hContainer);

ptwOneVal->ItemType = TWTY_FIX32;
memcpy((void *)&ptwOneVal->Item, &twFix32, sizeof(TW_FIX32));
GlobalUnlock(twBrightnessCap.hContainer);

L_TwainSetCapability (hSession, &twBrightnessCap, LTWAIN_CAPABILITY_SET);
}
break;

19.

In the IDM_ACQUIRE menu handler add the following code:

case IDM_ACQUIRE:
{
L_TwainEndCapsNeg(hSession);
if (LeadBitmap.Flags.Allocated)
{
L_FreeBitmap
 (&LeadBitmap);
L_InitBitmap (&LeadBitmap, sizeof(BITMAPHANDLE), 0, 0, 0);

L_TwainAcquire(hSession, &LeadBitmap, sizeof(BITMAPHANDLE), NULL, LTWAIN_SHOW_USER_INTERFACE, NULL, NULL);
}
}
break;

20.

Compile and test the program.


Twain Duplex Tutorial

Take the following steps to create and run a program that implements LEADTOOLS TWAIN features. Remember, the purpose of the TWAIN tutorial is to provide you a quick and easy way to generate a TWAIN program.

1. | Create a new directory in the LTWINxxx\EXAMPLES\DLL directory called EZTWNDuplex.
2. | Copy everything in the EZFUNC directory into the EZTWNDuplex directory.
3. | Rename the EZFunc.c file to be EZFunc.cpp.
4. | Remove the EXFunc.c from the project and add the EZFunc.cpp in its place.
5. | Compile the project as it is and run EZFUNC32.exe to familiarize yourself with the basic program. You can run the exe file from the MS-DOS prompt, or set the image file to load through the Project->Settings->Debug->Program Arguments menu.
6. | On the Insert menu, select Files into Project. Add the Lttwn_n.lib file to the project from the LTWINxxx\LIB directory.
7. | Define the following global variables in EZFUNC.CPP in the EZTWNDuplex directory:

HTWAINSESSION hSession = NULL;

8. | In the project workspace go to the resources tab. Add a menu ("MAIN_MENU") to the application with the following menu items:
 | ID | Caption
 | IDM_ACQUIRE | Acquire
9. | In the InitApplication function change the line:

wcWindowClass.lpszMenuName = NULL; /* No menu */
to be
wcWindowClass.lpszMenuName = TEXT("MAIN_MENU");

10.

In the EZFunc.cpp add the following includes:

#include "resource.h"

11.

In the MainWndProc function and before the handling of the WM_PALETTECHANGED message add the following code:

case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDM_ACQUIRE:
{
}
break;
}
break;

12.

In the IDM_ACQUIRE menu handler add the following code:

case IDM_ACQUIRE:
{
TwainTestDuplex(hWnd);
}

13.

Add the following function to the EZFUNC.CPP:

L_INT L_FAR L_EXPORT TwainAcquireCB(HTWAINSESSION hTwain, pBITMAPHANDLE pBitmap, L_VOID L_FAR * pUserData)
{
// ...
// set your code here ...
// ...

return(SUCCESS);
}

14.

Add the following function to the EZFUNC.CPP:

void TwainTestDuplex(HWND hWnd)
{
HTWAINSESSION hSession;
APPLICATIONDATA AppData;
L_INT nRet;
TW_CAPABILITY twCap;

memset(&AppData, 0, sizeof(APPLICATIONDATA));

AppData.hWnd = hWnd;
lstrcpy (AppData.szManufacturerName, TEXT("LEAD Technologies, Inc."));
lstrcpy (AppData.szAppProductFamily, TEXT("LEAD Sample"));
lstrcpy (AppData.szVersionInfo, TEXT("Version 1.0"));
lstrcpy (AppData.szAppName, TEXT("LEAD Sample"));
AppData.uStructSize = sizeof(APPLICATIONDATA);

nRet = L_TwainInitSession(&hSession, &AppData);
if (nRet != TWAIN_SUCCESS)
return;

L_TwainSelectSource(hSession, NULL);

L_TwainStartCapsNeg(hSession);

twCap.Cap = CAP_DUPLEX;
twCap.ConType = TWON_ONEVALUE;
twCap.hContainer = NULL;

nRet = L_TwainGetCapability(hSession, &twCap, LTWAIN_CAPABILITY_GETVALUES);
if (nRet == TWAIN_SUCCESS)
{
// check if the selected driver supports duplex capability
pTW_ONEVALUE pOneValue = (pTW_ONEVALUE)GlobalLock(twCap.hContainer);
if (pOneValue->ItemType != TWTY_UINT16)
{
GlobalUnlock(twCap.hContainer);
L_TwainFreeContainer(&twCap);
L_TwainEndCapsNeg(hSession);
L_TwainEndSession(&hSession);
return;
}

TW_UINT16 item = (TW_UINT16)pOneValue->Item;

switch (item)
{
case TWDX_NONE:
MessageBox(hWnd, TEXT("Duplex capability is not supported in the selected driver"), TEXT("Notice"), MB_OK);
break;
case TWDX_1PASSDUPLEX:
MessageBox(hWnd, TEXT("1 Pass Duplex capability is supported in the selected driver"), TEXT("Notice"), MB_OK);
break;
case TWDX_2PASSDUPLEX:
MessageBox(hWnd, TEXT("2 Pass Duplex capability is supported in the selected driver"), TEXT("Notice"), MB_OK);
break;
}

GlobalUnlock(twCap.hContainer);
L_TwainFreeContainer(&twCap);

// make sure the duplex capability is enabled
if (item != TWDX_NONE)
{
BOOL bEnable = TRUE;

twCap.Cap = CAP_DUPLEXENABLED;
twCap.ConType = TWON_ONEVALUE;
twCap.hContainer = GlobalAlloc(GHND, sizeof(TW_ONEVALUE));

pTW_ONEVALUE pOneValue = (pTW_ONEVALUE)GlobalLock(twCap.hContainer);
pOneValue->ItemType = TWTY_BOOL;
pOneValue->Item = (TW_UINT32)bEnable;

GlobalUnlock(twCap.hContainer);
nRet = L_TwainSetCapability(hSession, &twCap, LTWAIN_CAPABILITY_SET);
if (nRet == TWAIN_SUCCESS)
MessageBox(hWnd, TEXT("The duplex capability is enabled"), TEXT("Notice"), MB_OK);
else
MessageBox(hWnd, TEXT("Can't enable duplex capability"), TEXT("Notice"), MB_OK);
}
}
else
MessageBox(hWnd, TEXT("Duplex capability is not supported in the selected driver"), TEXT("Notice"), MB_OK);

L_TwainEndCapsNeg(hSession);

// try to acquire pages using duplex capability
L_TwainAcquire(hSession, NULL, sizeof(BITMAPHANDLE), TwainAcquireCB, LTWAIN_SHOW_USER_INTERFACE | LTWAIN_MODAL_USER_INTERFACE, NULL, NULL);

L_TwainEndSession(&hSession);
}

15.

Compile and test the program.


Twain Feeder : Tutorial # 1

Take the following steps to create and run a program that implements LEADTOOLS TWAIN features. Remember, the purpose of the TWAIN tutorial is to provide you a quick and easy way to generate a TWAIN program.

1. | Create a new directory in the LTWINxxx\EXAMPLES\DLL directory called EZTWNFEEDER1.
2. | Copy everything in the EZFUNC directory into the EZTWNFEEDER1 directory.
3. | Rename the EZFunc.c file to be EZFunc.cpp.
4. | Remove the EXFunc.c from the project and add the EZFunc.cpp in its place.
5. | Compile the project as it is and run EZFUNC32.exe to familiarize yourself with the basic program. You can run the exe file from the MS-DOS prompt, or set the image file to load through the Project->Settings->Debug->Program Arguments menu.
6. | On the Insert menu, select Files into Project. Add the Lttwn_n.lib file to the project from the LTWINxxx\LIB directory.
7. | Define the following global variables in EZFUNC.CPP in the EZTWNFEEDER1 directory:

HTWAINSESSION hSession = NULL;

8. | In the project workspace go to the resources tab. Add a menu ("MAIN_MENU") to the application with the following menu items:
 | ID | Caption
 | IDM_ACQUIRE | Acquire
9. | In the InitApplication function change the line:

wcWindowClass.lpszMenuName = NULL; /* No menu */
to be
wcWindowClass.lpszMenuName = TEXT("MAIN_MENU");

10.

In the EZFunc.cpp add the following includes:

#include "resource.h"

11.

In the MainWndProc function and before the handling of the WM_PALETTECHANGED message add the following code:

case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDM_ACQUIRE:
{
}
break;
}
break;

12.

In the IDM_ACQUIRE menu handler add the following code:

case IDM_ACQUIRE:
{
TwainTestFeeder1(hWnd);
}

13.

Add the following function to the EZFUNC.CPP:

L_INT L_FAR L_EXPORT TwainAcquireCB(HTWAINSESSION hTwain, pBITMAPHANDLE pBitmap, L_VOID L_FAR * pUserData)
{
// ...
// set your code here ...
// ...

return(SUCCESS);
}

14.

Add the following function to the EZFUNC.CPP:

void TwainTestFeeder1(HWND hWnd)
{
HTWAINSESSION hSession;
APPLICATIONDATA AppData;
TW_CAPABILITY twCap;
L_INT nRet;
L_BOOL bEnable;

memset(&AppData, 0, sizeof(APPLICATIONDATA));

AppData.hWnd = hWnd;
lstrcpy (AppData.szManufacturerName, TEXT("LEAD Technologies, Inc."));
lstrcpy (AppData.szAppProductFamily, TEXT("LEAD Sample"));
lstrcpy (AppData.szVersionInfo, TEXT("Version 1.0"));
lstrcpy (AppData.szAppName, TEXT("LEAD Sample"));
AppData.uStructSize = sizeof(APPLICATIONDATA);

nRet = L_TwainInitSession(&hSession, &AppData);
if (nRet != TWAIN_SUCCESS)
return;

L_TwainSelectSource(hSession, NULL);
L_TwainStartCapsNeg(hSession);

twCap.Cap = CAP_AUTOFEED;
twCap.ConType = TWON_ONEVALUE;
twCap.hContainer = GlobalAlloc(GHND, sizeof(TW_ONEVALUE));

pTW_ONEVALUE pOneValue = (pTW_ONEVALUE)GlobalLock(twCap.hContainer);
bEnable = TRUE;

pOneValue->ItemType = TWTY_BOOL;
pOneValue->Item = (TW_UINT32)bEnable;

GlobalUnlock(twCap.hContainer);

nRet = L_TwainSetCapability(hSession, &twCap, LTWAIN_CAPABILITY_SET);
if (nRet == TWAIN_SUCCESS)
MessageBox(hWnd, TEXT("AutoFeed capability is enabled"), TEXT("Notice"), MB_OK);
else
MessageBox(hWnd, TEXT("Can't enable AutoFeed capability"), TEXT("Notice"), MB_OK);

L_TwainEndCapsNeg(hSession);

// try to acquire pages using AutoFeed capability
L_TwainAcquire(hSession, NULL, sizeof(BITMAPHANDLE), TwainAcquireCB, LTWAIN_SHOW_USER_INTERFACE | LTWAIN_MODAL_USER_INTERFACE, NULL, NULL);

L_TwainEndSession(&hSession);
}

15.

Compile and test the program.


Twain Feeder : Tutorial # 2

Take the following steps to create and run a program that implements LEADTOOLS TWAIN features. Remember, the purpose of the TWAIN tutorial is to provide you a quick and easy way to generate a TWAIN program.

1. | Create a new directory in the LTWINxxx\EXAMPLES\DLL directory called EZTWNFEEDER2.
2. | Copy everything in the EZFUNC directory into the EZTWNFEEDER2 directory.
3. | Rename the EZFunc.c file to be EZFunc.cpp.
4. | Remove the EXFunc.c from the project and add the EZFunc.cpp in its place.
5. | Compile the project as it is and run EZFUNC32.exe to familiarize yourself with the basic program. You can run the exe file from the MS-DOS prompt, or set the image file to load through the Project->Settings->Debug->Program Arguments menu.
6. | On the Insert menu, select Files into Project. Add the Lttwn_n.lib file to the project from the LTWINxxx\LIB directory.
7. | Define the following global variables in EZFUNC.CPP in the EZTWNFEEDER2 directory:

HTWAINSESSION hSession = NULL;

8. | In the project workspace go to the resources tab. Add a menu ("MAIN_MENU") to the application with the following menu items:
 | ID | Caption
 | IDM_ACQUIRE | Acquire
9. | In the InitApplication function change the line:

wcWindowClass.lpszMenuName = NULL; /* No menu */
to be
wcWindowClass.lpszMenuName = TEXT("MAIN_MENU");

10.

In the EZFunc.cpp add the following includes:

#include "resource.h"

11.

In the MainWndProc function and before the handling of the WM_PALETTECHANGED message add the following code:

case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDM_ACQUIRE:
{
}
break;
}
break;

12.

In the IDM_ACQUIRE menu handler add the following code:

case IDM_ACQUIRE:
{
TwainTestFeeder2(hWnd);
}

13.

Add the following function to the EZFUNC.CPP:

L_INT L_FAR L_EXPORT TwainAcquireCB(HTWAINSESSION hTwain, pBITMAPHANDLE pBitmap, L_VOID L_FAR * pUserData)
{
// ...
// set your code here ...
// ...

return(SUCCESS);
}

14.

Add the following function to the EZFUNC.CPP:

void TwainTestFeeder2(HWND hWnd)
{
HTWAINSESSION hSession;
APPLICATIONDATA AppData;
TW_CAPABILITY twCap;
L_INT nRet;
L_BOOL bEnable;

memset(&AppData, 0, sizeof(APPLICATIONDATA));

AppData.hWnd = hWnd;
lstrcpy (AppData.szManufacturerName, TEXT("LEAD Technologies, Inc."));
lstrcpy (AppData.szAppProductFamily, TEXT("LEAD Sample"));
lstrcpy (AppData.szVersionInfo, TEXT("Version 1.0"));
lstrcpy (AppData.szAppName, TEXT("LEAD Sample"));
AppData.uStructSize = sizeof(APPLICATIONDATA);

nRet = L_TwainInitSession(&hSession, &AppData);
if (nRet != TWAIN_SUCCESS)
return;

L_TwainSelectSource(hSession, NULL);
L_TwainStartCapsNeg(hSession);

twCap.Cap = CAP_FEEDERENABLED;
twCap.ConType = TWON_ONEVALUE;
twCap.hContainer = GlobalAlloc(GHND, sizeof(TW_ONEVALUE));

pTW_ONEVALUE pOneValue = (pTW_ONEVALUE)GlobalLock(twCap.hContainer);
bEnable = TRUE;

pOneValue->ItemType = TWTY_BOOL;
pOneValue->Item = (TW_UINT32)bEnable;

GlobalUnlock(twCap.hContainer);

nRet = L_TwainSetCapability(hSession, &twCap, LTWAIN_CAPABILITY_SET);
if (nRet == TWAIN_SUCCESS)
{
MessageBox(hWnd, TEXT("CAP_FEEDERENABLED capability is enabled"), TEXT("Notice"), MB_OK);
L_TwainFreeContainer(&twCap);

// check if there is document loaded in the feeder
twCap.Cap = CAP_DUPLEX;
twCap.ConType = TWON_ONEVALUE;
twCap.hContainer = NULL;

nRet = L_TwainGetCapability(hSession, &twCap, LTWAIN_CAPABILITY_GETVALUES);
if (nRet == TWAIN_SUCCESS)
{
// check if the selected driver supports duplex capability
pOneValue = (pTW_ONEVALUE)GlobalLock(twCap.hContainer);
bEnable = pOneValue->Item;
if (bEnable)
MessageBox(hWnd, TEXT("There is document loaded in the feeder"), TEXT("Notice"), MB_OK);
else
MessageBox(hWnd, TEXT("There is no document loaded in the feeder"), TEXT("Notice"), MB_OK);

GlobalUnlock(twCap.hContainer);
L_TwainFreeContainer(&twCap);
}
}
else
MessageBox(hWnd, TEXT("Can't enable AutoFeed capability"), TEXT("Notice"), MB_OK);

L_TwainEndCapsNeg(hSession);

// try to acquire pages using CAP_FEEDERENABLED and CAP_FEEDERLOADED capabilities
L_TwainAcquire(hSession, NULL, sizeof(BITMAPHANDLE), TwainAcquireCB, LTWAIN_SHOW_USER_INTERFACE | LTWAIN_MODAL_USER_INTERFACE, NULL, NULL);
L_TwainEndSession(&hSession);
}

15.

Compile and test the program.


LTWAINACQUIRECALLBACK

LTWAINACQUIRECALLBACK Function

#include "lttw2.h"

L_VOID pEXT_CALLBACK YourFunction (hSession, nPage, pszFileName, bFinishScan, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_INT nPage; | /* page number */
L_TCHAR L_FAR * pszFileName; | /* File name */
L_BOOL bFinishScan; | /* flag to determine if the scanning status */
L_VOID *pUserData; | /* pointer to additional parameters */

Called twice for each scanned page. The address of this callback is passed as an argument to L_TwainAcquireMulti. This function is available in the Document/Medical Toolkits.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
nPage | Number of the page being acquired
pszFileName | Character string containing the name of the file in which to save the scanned image(s).
bFinishScan | Flag that indicates the scanning status. Possible values are:
 | Value | Meaning
 | TRUE | Scanning of the page has finished.
 | FALSE | Scanning of the page has just started.
pUserData | A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of L_TwainAcquireMulti.)
 | Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function

Comments

This callback will be called two times. The callback is called the first time when the Twain source begins scanning the page. The callback is called the second time when the Twain source has finished scanning the page.

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: | L_TwainAcquire, L_TwainAcquireList, L_TwainInitSession, L_TwainEndSession, L_TwainOpenTemplateFile, L_TwainCloseTemplateFile, L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetNumofCapsInFile, L_TwainGetCapabilityFromFile, L_TwainAcquireMulti, L_TwainFindFastConfig, L_TwainGetScanConfigs, L_TwainFreeScanConfig.
Topics: | How to Acquire from the Twain Source
 | TWAIN Functionality:Property Functions

Example

For a complete sample, refer to the TWNCONFIG demo

For an example, refer to L_TwainAcquireMulti.


LTWAINBITMAPCALLBACK Function

#include "lttw2.h"

L_INT pEXT_CALLBACK YourFunction (hSession, pBitmap, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pBITMAPHANDLE * pBitmap; | /* pointer to the bitmap handle */
L_VOID * pUserData; | /* pointer to additional parameters */

Called for each image being acquired from the TWAIN source to the application. The address of this callback is passed as an argument in L_TwainAcquire.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pBitmap | Pointer to the bitmap handle that references the bitmap acquired from the TWAIN source. It is the same bitmap handle that you specify when calling the L_TwainAcquire function.
pUserData | A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of L_TwainAcquire.)
 | Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

Returns

SUCCESS | The function was successful.
SUCCESS_ABORT | The callback wants to abort the scanning operation.
< 1 | An error occurred. Refer to Return Codes.

Comments

To prevent memory leaks, the user should free the bitmap within the callback function.

The L_TwainGetExtendedImageInfo function can only be called within the callback.

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: | L_TwainAcquire, L_TwainGetExtendedImageInfo
Topics: | TWAIN Functionality: Callback Functions.

Example

For an example, refer to L_TwainAcquire.


LTWAINCAPABILITYCALLBACK Function

#include "lttw2.h"

L_INT pEXT_CALLBACK YourFunction (hSession, uCap, pCapabiltiy, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_UINT uCap; | /* capability received */
pTW_CAPABILITY * pCapability; | /* pointer to a structure */
L_VOID * pUserData; | /* pointer to additional parameters */

Called for each capability enumerated by the L_TwainEnumCapabilities function. The address of this callback is passed as an argument in L_TwainEnumCapabilities.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
uCap | The capability being enumerated. For more information on capability values, refer to the Twain 1.9 Specification, available at www.twain.org.
pCapability | Pointer to the TW_CAPABILITY structure that references the capability data being enumerated. For more information about TW_CAPABILITY, refer to the TWAIN 1.9 specification from the site http://www.twain.org/.
pUserData | A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of L_TwainEnumCapabilities.)
 | Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

Returns

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

Comments

To prevent memory leaks, the user should free the pointer to TW_CAPABILITY structure within the callback function.

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: | L_TwainEnumCapabilities.
Topics: | TWAIN Functionality: Callback Functions.

Example

For an example, refer to L_TwainStartCapsNeg.


LTWAINFINDFASTCONFIG

#include "lttw2.h"

L_INT pEXT_CALLBACK YourFunction(hSession, pResConfig, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pFASTCONFIG pResConfig; | /* pointer to a FASTCONFIG structure */
L_VOID *pUserData; | /* pointer to additional parameters */

Called for each configuration test. The address of this callback is passed as an argument to L_TwainFindFastConfig. This function is available in the Document/Medical Toolkits.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pResConfig | Pointer to a FASTCONFIG structure that contains the scan configuration that is currently being tested.
pUserData | A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of L_TwainFindFastConfig.)
 | Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

Returns

SUCCESS | The function was successful.
SUCCESS_ABORT | Abort the testing configuration.

Comments

If you return SUCCESS, then the scan configuration testing process will be continued, otherwise, the process will be stopped.

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: | L_TwainAcquire, L_TwainAcquireList, L_TwainInitSession, L_TwainEndSession, L_TwainOpenTemplateFile, L_TwainCloseTemplateFile, L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetNumofCapsInFile, L_TwainGetCapabilityFromFile, L_TwainAcquireMulti, L_TwainFindFastConfig, L_TwainGetScanConfigs, L_TwainFreeScanConfig
Topics: | Scan Configurations
 | TWAIN Functionality: Scan Configuration Functions.

Example

For a complete sample, refer to the TWNCONFIG demo.

For an example, refer to L_TwainFindFastConfig.


LTWAINSAVECAPCALLBACK Function

#include "lttw2.h"

L_INT pEXT_CALLBACK YourFunction (hSession, pCapability, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_CAPABILITY pCapability; | /* pointer to a structure */
L_VOID * pUserData; | /* pointer to additional parameters */

Called for each capability supported by a particular TWAIN source, before saving it to a specific template file. The address of this callback is passed as an argument in L_TwainTemplateDlg.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pCapability | Pointer to the TW_CAPABILITY structure that references the capability data to save to the specified template file. For more information about TW_CAPABILITY, refer to the TWAIN 1.9 specification from the site http://www.twain.org/.
pUserData | A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of L_TwainTemplateDlg.)
 | Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

Returns

SUCCESS | The function was successful.
SUCCESS_ABORT | The callback wants to abort the saving procedure.
SUCCESS_DELETE | Abort saving procedure and delete the file.
< 1 | An error occurred. Refer to Return Codes.

Comments

The user can only modify the capability data before saving it to the specified template file.

The user should not free the pointer to the TW_CAPABILITY structure within this callback.

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: | L_TwainTemplateDlg.
Topics: | TWAIN Functionality: Callback Functions.

Example

For an example, refer to L_TwainTemplateDlg.


LTWAINSAVEERRORCALLBACK Function

#include "lttw2.h"

L_INT pEXT_CALLBACK YourFunction (hSession, pCapability, uError, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_CAPABILITY pCapability; | /* pointer to a structure */
L_UINT uError; | /* error code */
L_VOID * pUserData; | /* pointer to additional parameters */

Called when an error occurs while saving capability data supported by a particular TWAIN source to a specific template file. The address of this callback is passed as an argument in L_TwainTemplateDlg.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pCapability | Pointer to the TW_CAPABILITY structure that references the capability data that was being saved to a specific template file when the error occurred. For more information about TW_CAPABILITY, refer to the TWAIN 1.9 specification from the site http://www.twain.org/.
uError | Error code.
pUserData | A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of L_TwainTemplateDlg.)
 | Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

Returns

SUCCESS | The function was successful.
SUCCESS_RETRY | Retry saving the capability value.
SUCCESS_ABORT | Abort the saving procedure.
SUCCESS_DELETE | Abort saving procedure and delete the file.

Comments

The user should not free the pointer to the TW_CAPABILITY structure within this callback.

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: | L_TwainTemplateDlg.
Topics: | TWAIN Functionality: Callback Functions.

Example

For an example, refer to L_TwainTemplateDlg.


LTWAINSETPROPERTYCALLBACK Function

#include "lttw2.h"

L_INT pEXT_CALLBACK YourFunction (hSession, uCap, nStatus, pValue, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_UINT uCap; | /* capability being set */
L_INT nStatus; | /* status variable */
L_VOID * pValue; | /* pointer to the original value */
L_VOID * pUserData; | /* pointer to additional parameters */

Called for each property set. The address of this callback is passed as an argument to L_TwainSetProperties.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
uCap | The capability being set.
nStatus | This variable holds the value of the error that occurred while the property was being set.
pValue | Pointer to the original value. The user can cast this depending on the type of the property, and modify it.
pUserData | A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of L_TwainSetProperties.)
 | Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

Returns

SUCCESS | The function was successful.
SUCCESS_RETRY | Retry with the new value in *pValue parameter.
SUCCESS_ABORT | Abort the negotiation.

Comments

The user should not free the pValue parameter within this callback.

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: | L_TwainSetProperties.
Topics: | TWAIN Functionality: Callback Functions

Example

For an example, refer to L_TwainGetProperties.


LTWAINSOURCEINFOCALLBACK Function

#include "lttw2.h"

L_INT pEXT_CALLBACK YourFunction (hSession, pSourceInfo, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pLTWAINSOURCEINFO * pSourceInfo; | /* pointer to the LTWAINSOURCEINFO structure */
L_VOID * pUserData; | /* pointer to additional parameters */

Called for each available TWAIN source installed on the system. The address of this callback is passed as an argument in L_TwainGetSources.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pSourceInfo | Pointer to the LTWAINSOURCEINFO structure that contains the name of the TWAIN source retrieved.
pUserData | A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass in the pUserData parameter of L_TwainGetSources.)
 | Keep in mind that this is a void pointer, which must be cast to the appropriate data type within your callback function.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

This callback function gets the available information about the installed TWAIN sources on the system like the names of the TWAIN source, the scanner product family, and the manufacturer.

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: | L_TwainGetSources.
Topics: | TWAIN Functionality: Callback Functions

Example

For an example, refer to L_TwainGetSources.


L_IsTwainAvailable

#include "lttw2.h"

L_BOOL EXT_FUNCTION L_IsTwainAvailable(hWnd)

HWND hWnd;

/* handle to a window */

Determines whether a TWAIN source is installed.

Parameter | Description
hWnd | Handle to a window. (Internal TWAIN functions require a window handle; any valid window handle will work in this case.)

Returns

TRUE | At least one TWAIN source is installed.
FALSE | No TWAIN source is installed.

Comments

You can use this function when deciding whether to enable or disable TWAIN menu items.

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: | L_TwainAcquire, L_TwainAcquireList, L_TwainInitSession, L_TwainEndSession, L_TwainOpenTemplateFile, L_TwainCloseTemplateFile, L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetNumofCapsInFile, L_TwainGetCapabilityFromFile.
Topics: | TWAIN Functionality: Property Functions

Example

void TestTWAIN2(HWND hWnd, HBITMAPLIST hBitmap)
{
L_BOOL bAvailable;
L_INT nRet;
HTWAINSESSION hSession = NULL;
APPLICATIONDATA AppData;

/* Check to see if TWAIN is installed */
bAvailable = L_IsTwainAvailable(hWnd);
if (bAvailable)
{
AppData.uStructSize = sizeof(APPLICATIONDATA);
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 = L_TwainInitSession(&hSession, &AppData);
if (nRet != SUCCESS)
return;

L_TwainAcquireList(hSession, hBitmap, NULL, LTWAIN_SHOW_USER_INTERFACE);
L_TwainEndSession(&hSession);
}
}


L_TwainAcquire

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainAcquire (hSession, pBitmap, uStructSize, pfnCallBack, uFlags, lpszTemplateFile, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pBITMAPHANDLE pBitmap; | /* pointer to the bitmap handle */
L_UINT uStructSize; | /* size in bytes, of the structure pointed to by pBitmap */
LTWAINBITMAPCALLBACK pfnCallBack; | /* callback function */
L_UINT uFlags; | /* optional flags */
L_TCHAR * lpszTemplateFile; | /* template file name */
L_VOID * pUserData; | /* pointer to more parameters for the callback */

Acquires one or more images from a TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pBitmap | Pointer to the bitmap handle that references the last bitmap acquired from the TWAIN source.
uStructSize | Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).
pfnCallBack | Optional callback function for multipage scanning. Use NULL as the value of this parameter if you are processing only one image. If you provide a callback function, use the function pointer as the value of this parameter.
 | L_TwainAcquire calls this callback function as it acquires each page into the bitmap. The callback function must adhere to the following function prototype: LTWAINBITMAPCALLBACK.
uFlags | Flag that determines certain actions of the TWAIN source. Possible values are:
 | Value | Meaning
 | 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.
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.
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

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

When acquiring multiple pages, the LTWAINBITMAPCALLBACK callback 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 TWAIN acquisition process started by calling this function, call L_TwainCancelAcquire within the LTWAINBITMAPCALLBACK function.

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: | L_TwainAcquireList, L_TwainInitSession, L_TwainEndSession, L_TwainOpenTemplateFile, L_TwainCloseTemplateFile, L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetNumofCapsInFile, L_TwainGetCapabilityFromFile, L_TwainCancelAcquire
Topics: | How to Acquire from the TWAIN Source
 | TWAIN Functionality: Property Functions.

Example

HTWAINSESSION g_hSession;

L_INT EXT_CALLBACK BmpCB (HTWAINSESSION hSession, pBITMAPHANDLE pBitmap, L_VOID * pUserData)
{
// You can do here any processing to the bitmap

return SUCCESS;
}

void TwainAcquire (pBITMAPHANDLE pBitmap)
{
L_INT nRet;
TW_CAPABILITY twCap;

// Show the Twain Select Source UI
nRet = L_TwainSelectSource(g_hSession, NULL);
if (nRet != SUCCESS)
MessageBox (NULL, TEXT("Error occurred while selecting the source."),TEXT( "ERROR"), MB_OK);

L_TwainStartCapsNeg(g_hSession);

twCap.Cap = ICAP_XFERMECH;
twCap.ConType = TWON_ONEVALUE;

L_TwainCreateNumericContainerOneValue(&twCap, TWAINNUMERICTYPE_TW_UINT16, TWSX_NATIVE);

L_TwainSetCapability(g_hSession, &twCap, LTWAIN_CAPABILITY_SET);
L_TwainFreeContainer(&twCap);
L_TwainEndCapsNeg(g_hSession);

nRet = L_TwainAcquire(g_hSession, pBitmap, sizeof(BITMAPHANDLE), BmpCB, LTWAIN_SHOW_USER_INTERFACE, NULL, 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);
}


L_TwainAcquireList

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainAcquireList (hSession, hBitmap, lpszTemplateFile, uFlags)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
HBITMAPLIST hBitmap; | /* handle to the list of bitmaps */
L_TCHAR * lpszTemplateFile; | /* template file name */
L_UINT uFlags; | /* optional flags */

Acquires one or more pages from a TWAIN source and stores the images in the specified bitmap list.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
hBitmap | Handle to the list of bitmaps acquired from the selected TWAIN source.
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 Settings Capabilities.
uFlags | Flag that determines certain actions of the TWAIN source. Possible values are:
 | Value | Meaning
 | 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.

Returns

SUCCESS The function was successful.

! = SUCCESS An error occurred. Refer to Return Codes.

Comments

This function acquires one or more images from a TWAIN source and stores them in the specified bitmap list. If the user wants to acquire one or more images and process each one individually, he or she should use the L_TwainAcquire function an provide a LTWAINBITMAPCALLBACK function for processing each 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.

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: | L_TwainAcquire, L_TwainInitSession, L_TwainEndSession, L_TwainOpenTemplateFile, L_TwainCloseTemplateFile, L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetNumofCapsInFile, L_TwainGetCapabilityFromFile.
Topics: | How to Acquire from the TWAIN Source
 | TWAIN Functionality: Property Functions.

Example

For an example, refer to L_IsTwainAvailable.


L_TwainAcquireMulti

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainAcquireMulti(hSession, pszBaseFileName, uFlags, uTransferMode, nFormat, nBitsPerPixel, bMultiPageFile, uUserBufSize, bUsePreferredBuffer, pfnCallBack, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
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 */
LTWAINACQUIRECALLBACK pfnCallBack; | /* optional callback function */
L_VOID * pUserData; | /* pointer to more parameters for the callback */

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
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pszBaseFileName | Character string containing the base name of the image file(s) in which to save the acquired data.
uFlags | Flag that determines certain actions of the TWAIN source. Possible values are:
 | Value | Meaning
 | 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.
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.
pfnCallBack | Optional callback function, called twice for each page scan. The 1st call is to notify the page is start scanning, and the 2nd call is to notify the page scanning is finished. If you do not provide a callback function, use NULL as the value of this parameter. No error reporting will occur. If you do provide a callback function, use the function pointer as the value of this parameter. The callback function must adhere to the function prototype described in the LTWAINACQUIRECALLBACK function.
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.

Returns

SUCCESS | The function was successful.
! = SUCCESS | 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 L_TwainFindFastConfig to determine the best scan configuration and then pass the scan configuration information to the L_TwainAcquireMulti function. If you do not call L_TwainFindFastConfig before calling L_TwainAcquireMulti, then the L_TwainAcquireMulti 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 TWAIN acquisition process started by calling this function, call L_TwainCancelAcquire within the LTWAINACQUIRECALLBACK function.

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: | L_TwainAcquire, L_TwainAcquireList, L_TwainInitSession, L_TwainEndSession, L_TwainOpenTemplateFile, L_TwainCloseTemplateFile, L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetNumofCapsInFile, L_TwainGetCapabilityFromFile, L_TwainFindFastConfig, L_TwainGetScanConfigs, L_TwainFreeScanConfig, L_TwainCancelAcquire
Topics: | How to Acquire from the TWAIN Source
 | TWAIN Functionality: Property Functions.

Example

For complete sample, refer to FASTTWN demo.

L_VOID EXT_CALLBACK AcquireMultiCB(HTWAINSESSION hSession, L_INT nPage, L_TCHAR L_FAR * pszFileName, L_BOOL bFinishScan, L_VOID *pUserData)
{
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, HTWAINSESSION hSession)
{
L_INT nRet;

nRet = L_TwainAcquireMulti(hSession,
TEXT("c:\\TWAIN\\test.tif"),
LTWAIN_SHOW_USER_INTERFACE,
LTWAIN_BUFFER_MODE,
FILE_TIF,
1,
TRUE,
0,
FALSE,
AcquireMultiCB, NULL);

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;
}


L_TwainAddCapabilityToFile

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainAddCapabilityToFile (hSession, hFile, ptwCapability)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
HTWAINTEMPLATEFILE hFile; | /* handle to an existing template file */
pTW_CAPABILITY ptwCapability; | /* pointer to a structure */

Adds a capability to a file.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
hFile | Handle to an existing template file.
ptwCapability | Pointer to a structure that contains the capability to add.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

In order to add a capability to a template file, the template file must first be opened for writing using the L_TwainOpenTemplateFile. Opening the file for writing will create a new empty file. The process of adding capabilities to the file will add them sequentially. When all capabilities have been added, save the file by calling L_TwainCloseTemplateFile. For more information on capabilities, refer to Getting and Setting Capabilities.

For more information on Template files, refer to Handling Template Files.

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: | L_TwainOpenTemplateFile, L_TwainTemplateDlg, L_TwainGetCapabilityFromFile, L_TwainGetNumOfCapsInFile, L_TwainCloseTemplateFile, L_TwainInitSession, L_TwainEndSession.
Topics: | Handling Template Files
 | TWAIN Functionality: Capability Functions.

Example

HTWAINSESSION g_hSession;
OPENFILENAME ofn;
L_INT nRet;
HTWAINTEMPLATEFILE hFile;
L_TCHAR szFilePath [MAX_PATH];
HWND hDlg; // Parent dialog handle

memset (&ofn, 0, sizeof(OPENFILENAME));
memset (szFilePath, 0, MAX_PATH);
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hDlg;
ofn.lpstrFile = szFilePath;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrTitle = TEXT("Save Template File");

if (GetSaveFileName (&ofn))
{
nRet = L_TwainOpenTemplateFile (g_hSession, &hFile, szFilePath, LTWAIN_TEMPLATE_OPEN_WRITE);
if (nRet == SUCCESS)
{
L_TwainEnumCapabilities (g_hSession, SaveCapsCB, LTWAIN_CAPABILITY_GETCURRENT, hFile);
L_TwainCloseTemplateFile (g_hSession, hFile);
}
}

L_INT CALLBACK SaveCapsCB (HTWAINSESSION hSession, L_UINT uCap, pTW_CAPABILITY pCapability, L_VOID * pUserData)
{
L_INT nRet;
HTWAINTEMPLATEFILE hFile = NULL;

if (!pUserData)
return SUCCESS;

hFile = (HTWAINTEMPLATEFILE)pUserData;
if (!pCapability)
return SUCCESS;

if (!pCapability->hContainer)
GlobalFreePtr (pCapability);

nRet = L_TwainAddCapabilityToFile (hSession, hFile, pCapability);

GlobalFree (pCapability->hContainer);
GlobalFreePtr (pCapability);

return SUCCESS;
}


L_TwainCloseTemplateFile

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainCloseTemplateFile (hSession, hFile)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
HTWAINTEMPLATEFILE hFile; | /* handle to an existing template file */

Closes the opened template file.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
hFile | Handle to an existing template file.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Closes and saves the template file opened by calling the L_TwainOpenTemplateFile function.

For more information on template files, refer to Handling Template Files.

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: | L_TwainOpenTemplateFile, L_TwainAddCapabilityToFile, L_TwainGetCapabilityFromFile, L_TwainGetNumOfCapsInFile, L_TwainTemplateDlg, L_TwainInitSession, L_TwainEndSession.
Topics: | Handling Template Files
 | TWAIN Functionality: Template File Functions.

Example

For an example, refer to L_TwainAddCapabilityToFile.


L_TwainCreateNumericContainerArray

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainCreateNumericContainerArray (pCapability, Type, uNumOfItems, pData)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
LTWAINNUMERICTYPE Type; | /* container type */
L_UINT32 uNumOfItems; | /* number of items in the array */
L_VOID * pData; | /* pointer to an allocated array */

Allocates the hContainer member of the TW_CAPABILITY structure to be type TW_ARRAY and fills it with the appropriate data.

Parameter | Description
pCapability | Pointer to a structure that contains the capability container to allocate as type TW_ARRAY.
Type | Type of data contained in the TW_ARRAY container. For a list of possible values, refer to LTWAINNUMERICTYPE.
uNumOfItems | Number of items in the array.
pData | Pointer to an allocated array of type TW_ARRAY that has been initialized with the appropriate data and size information.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

When enumerating and getting capabilities, the toolkit takes care of creating the necessary TW_CAPABILITY containers. However, if the user wants to set a capability using the L_TwainSetCapability function, he or she must declare a TW_CAPABILITY container of the appropriate type (TW_ARRAY, TW_ENUMERATION, TW_RANGE, or TW_ONEVALUE).

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: | L_TwainFreeContainer, L_TwainCreateNumericContainerRange, L_TwainCreateNumericContainerOneValue, L_TwainCreateNumericContainerEnum, L_TwainLockContainer, L_TwainUnlockContainer.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

HTWAINSESSION g_hSession;
TW_CAPABILITY twCap;
L_INT nItem[3];

memset (&twCap, 0, sizeof(TW_CAPABILITY));

twCap.Cap = ICAP_FILTER;
twCap.ConType = TWON_ARRAY;

nItem[0] = TWFT_RED;
nItem[1] = TWFT_GREEN;
nItem[2] = TWFT_BLUE;

L_TwainStartCapsNeg(g_hSession);

L_TwainCreateNumericContainerArray(&twCap, TWAINNUMERICTYPE_TW_UINT32, 3, (L_VOID *)nItem);

L_TwainSetCapability(g_hSession, &twCap, LTWAIN_CAPABILITY_SET);
L_TwainFreeContainer(&twCap);
L_TwainEndCapsNeg(g_hSession);


L_TwainCreateNumericContainerEnum

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainCreateNumericContainerEnum (pCapability, Type, uNumOfItems, uCurrentIndex, uDefaultIndex, pData)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
LTWAINNUMERICTYPE Type; | /* container type */
L_UINT32 uNumOfItems; | /* number of enumeration items */
L_UINT32 uCurrentIndex; | /* current index */
L_UINT32 uDefaultIndex; | /* default index */
L_VOID * pData; | /* pointer to an allocated array */

Allocates the hContainer member of the TW_CAPABILITY structure to be type TW_ENUMERATION and fills it with the appropriate data.

Parameter | Description
pCapability | Pointer to a structure that contains the capability container to allocate as type TW_ENUMERATION.
Type | Type of data contained in the TW_ENUMERATION container. For a list of possible values, refer to LTWAINNUMERICTYPE.
uNumOfItems | Number of items in the enumeration.
uCurrentIndex | Index of the current value in the enumeration data.
uDefualtIndex | Index of the default value in the enumeration data.
pData | Pointer to an allocated array of type TW_ENUMERATION that has been initialized with the appropriate data and size information.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

When enumerating and getting capabilities, the toolkit takes care of creating the necessary TW_CAPABILITY containers. However, if the user wants to set a capability using the L_TwainSetCapability function, he or she must declare a TW_CAPABILITY container of the appropriate type (TW_ARRAY, TW_ENUMERATION, TW_RANGE, or TW_ONEVALUE).

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: | L_TwainFreeContainer, L_TwainCreateNumericContainerRange, L_TwainCreateNumericContainerOneValue, L_TwainCreateNumericContainerArray, L_TwainLockContainer, L_TwainUnlockContainer.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

TW_CAPABILITY twCap;
L_UINT16 uItem[3];

memset (&twCap, 0, sizeof(TW_CAPABILITY));

twCap.Cap = ICAP_XFERMECH;
twCap.ConType = TWON_ENUMERATION;

uItem[0] = TWSX_FILE;
uItem[1] = TWSX_MEMORY;
uItem[2] = TWSX_NATIVE;

L_TwainCreateNumericContainerEnum(&twCap, TWAINNUMERICTYPE_TW_UINT32, 3, TWSX_MEMORY, TWSX_NATIVE, (L_VOID *)uItem);

L_TwainStartCapsNeg(g_hSession);
L_TwainSetCapability(g_hSession, &twCap, LTWAIN_CAPABILITY_SET);
L_TwainFreeContainer(&twCap);
L_TwainEndCapsNeg(g_hSession);


L_TwainCreateNumericContainerOneValue

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainCreateNumericContainerOneValue (pCapability, Type, uValue)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
LTWAINNUMERICTYPE Type; | /* container type */
L_UINT32 uValue; | /* TW_ONEVALUE value */

Allocates the hContainer member of the TW_CAPABILITY structure to be type TW_ONEVALUE and fills it with the appropriate data.

Parameter | Description
pCapability | Pointer to a structure that contains the capability container to allocate as type TW_ONEVALUE.
Type | Type of data contained in the TW_ONEVALUE container. For a list of possible values, refer to LTWAINNUMERICTYPE.
uValue | Value of the TW_ONEVALUE structure.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

When enumerating and getting capabilities, the toolkit takes care of creating the necessary TW_CAPABILITY containers. However, if the user wants to set a capability using the L_TwainSetCapability function, he or she must declare a TW_CAPABILITY container of the appropriate type (TW_ARRAY, TW_ENUMERATION, TW_RANGE, or TW_ONEVALUE).

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: | L_TwainFreeContainer, L_TwainCreateNumericContainerRange, L_TwainCreateNumericContainerEnum, L_TwainCreateNumericContainerArray, L_TwainLockContainer, L_TwainUnlockContainer.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

For an example, refer to L_TwainAcquire.


L_TwainCreateNumericContainerRange

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainCreateNumericContainerRange (pCapability, Type, uMinValue, uMaxValue, uStepSize, uDefaultValue, uCurrentValue)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
LTWAINNUMERICTYPE Type; | /* container type */
L_UINT32 uMinValue; | /* minimum range value */
L_UINT32 uMaxValue; | /* maximum range value */
L_UINT32 uStepSize; | /* step size of the range */
L_UINT32 uDefaultValue; | /* range default value */
L_UINT32 uCurrentValue; | /* range current value */

Allocates the hContainer member of the TW_CAPABILITY structure to be type TW_RANGE and fills it with the appropriate data.

Parameter | Description
pCapability | Pointer to a structure that contains the capability container to allocate as type TW_RANGE.
Type | Type of data contained in the TW_RANGE container. For a list of possible values, refer to LTWAINNUMERICTYPE.
uMinValue | The minimum value of the range.
uMaxValue | The maximum value of the range.
uStepSize | The step size value of the range.
uDefaultValue | The default value of the range.
uCurrentValue | The current value of the range.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

When enumerating and getting capabilities, the toolkit takes care of creating the necessary TW_CAPABILITY containers. However, if the user wants to set a capability using the L_TwainSetCapability function, he or she must declare a TW_CAPABILITY container of the appropriate type (TW_ARRAY, TW_ENUMERATION, TW_RANGE, or TW_ONEVALUE).

The step size is the amount of increase from one step to the next within the range uMinVal to uMaxVal. For example, if uMinValue = 0, uMaxValue = 100, and uStepSize = 2, then it will take 50 steps to increase from 0 to 100.

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: | L_TwainFreeContainer, L_TwainCreateNumericContainerOneValue, L_TwainCreateNumericContainerEnum, L_TwainCreateNumericContainerArray, L_TwainLockContainer, L_TwainUnlockContainer.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

TW_CAPABILITY twCap;

memset (&twCap, 0, sizeof(TW_CAPABILITY));

twCap.Cap = ICAP_XRESOLUTION;
twCap.ConType = TWON_RANGE;

L_TwainCreateNumericContainerRange(&twCap, TWAINNUMERICTYPE_TW_FIX32, 100, 600, 100, 200, 300);

L_TwainStartCapsNeg(g_hSession);
L_TwainSetCapability(g_hSession, &twCap, LTWAIN_CAPABILITY_SET);
L_TwainFreeContainer(&twCap);
L_TwainEndCapsNeg(g_hSession);


L_TwainEnableDuplex

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainEnableDuplex(hSession, bEnableDuplex)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_BOOL bEnableDuplex; | /* flag */

Enables or disables the duplex mode.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
bEnableDuplex | Flag that indicates whether to enable or disable the duplex mode. Possible values are:
 | Value | Meaning
 | TRUE | Enables the duplex mode.
 | FALSE | Disables the duplex mode.

Returns

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

Comments

This function internally sets the duplex enabled capability CAP_DUPLEXENABLED. For more information on these capabilities, refer to www.twain.org/download.htm and click on the TWAIN Specification (Version 1.9).

To get the current values of these capabilities, call the L_TwainGetDuplexOptions function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

void TestDuplexOptions(HTWAINSESSION hSession)
{
L_TwainStartCapsNeg (hSession);

L_BOOL bEnableDuplex;
L_INT nDuplexMode;
L_TwainGetDuplexOptions (hSession, &bEnableDuplex, &nDuplexMode);
if (bEnableDuplex != TRUE)
L_TwainEnableDuplex(hSession, TRUE);

L_INT nMaxXfer;
L_TwainGetMaxXferCount (hSession, &nMaxXfer);
if (nMaxXfer != 10)
L_TwainSetMaxXferCount (hSession, 10);

L_TwainEndCapsNeg (hSession);
}


L_TwainEnableShowUserInterfaceOnly

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainEnableShowUserInterfaceOnly (hSession, bEnable)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_BOOL bEnable; | /* enable flag */

Indicates whether to display the Twain user interface with or without the Scan button, if supported.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
uFlags | Flag that indicates whether to display the user interface. Possible values are:
 | Value | Meaning
 | TRUE | Display the Twain user interface without the scan button, if supported.
 | FALSE | Display the normal Twain driver user interface with the scan button. (Default)

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

To display the Twain driver user interface without the scan button, call this function with the bEnable parameter set to true. Then call L_TwainTemplateDlg to display the template dialog.

If you call this function with the bEnable parameter set to false, the template dialog will display the normal Twain user interface, with the scan button.

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

Function: | L_TwainInitSession, L_TwainTemplateDlg.
Topics: | Handling Template Files
 | TWAIN Functionality: Template File Functions.

Example

void TestTemplateDlg(L_CHAR L_FAR * pszFileName)
{
L_TwainEnableShowUserInterfaceOnly(g_hSession, TRUE);
L_TwainTemplateDlg (g_hSession, pszFileName, NULL, NULL, NULL);
}


L_TwainEndCapsNeg

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainEndCapsNeg (hSession)

HTWAINSESSION hSession;

/* handle to an existing TWAIN session */

Ends the process of getting and setting TWAIN capabilities.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

The process of getting and setting TWAIN capabilities is started by calling L_TwainStartCapsNeg.

When the user has retrieved and set all the desired capabilities, this function must be called to free the data allocated by the L_TwainStartCapsNeg function. For every call to L_TwainStartCapsNeg there must be a call to L_TwainEndCapsNeg.

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: | L_TwainStartCapsNeg, L_TwainSetProperties, L_TwainGetProperties, L_TwainSetCapability, L_TwainGetCapability, L_TwainInitSession.
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions.

Example

For an example, refer to L_TwainAcquire.


L_TwainEndSession

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainEndSession (phSession)

pHTWAINSESSION phSession;

/* handle to an existing session handle */

Ends a TWAIN session.

Parameter | Description
phSession | Pointer to a handle to an existing TWAIN session, created by calling the L_TwainInitSession function.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

A TWAIN session is started by calling the L_TwainInitSession function.

For each call to L_TwainInitSession there must be a call to L_TwainEndSession. This function should be the last function to be called in the toolkit. It will clean up and free memory allocated during the TWAIN session.

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: | L_TwainInitSession.
Topics: | Freeing the TWAIN Session
 | TWAIN Functionality: Session Functions.

Example

For an example, refer to L_IsTwainAvailable.


L_TwainEnumCapabilities

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainEnumCapabilities (hSession, pfnCallBack, uFlags, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
LTWAINCAPABILITYCALLBACK * pfnCallBack; | /* optional callback function */
L_UINT uFlags; | /* optional flags */
L_VOID * pUserData; | /* pointer to more parameters for the callback */

Gets the supported capabilities and specified value(s) of each capability.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pfnCallBack | Callback function for processing each enumerated capability. Use the function pointer as the value of this parameter.
 | L_TwainEnumCapabilities calls this callback function as it gets each TWAIN capability. The callback function must adhere to the function prototype described in LTWAINCAPABILITYCALLBACK Function.
uFlags | Flags that indicate the capability values to get when enumerating the TWAIN capability. Possible values are:
 | Value | Meaning
 | LTWAIN_CAPABILITY_DONTGET | [0] Get no capability values.
 | LTWAIN_CAPABILITY_GETCURRENT | [3] Get the current capability value.
 | LTWAIN_CAPABILITY_GETDEFAULT | [4] Get the default capability value.
 | LTWAIN_CAPABILITY_GETVALUES | [5] Get all available capability values.
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

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

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: | L_TwainStartCapsNeg, L_TwainEndCapsNeg, L_TwainSetProperties, L_TwainGetProperties, L_TwainSetCapability, L_TwainGetCapability, L_TwainInitSession, L_TwainEndSession.
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions.

Example

For an example, refer to L_TwainAddCapabilityToFile.


L_TwainFindFastConfig

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainFindFastConfig(hSession, pszWorkingFolder, uFlags, nBitsPerPixel, nBufferIteration, pInFastConfigs, nInFastConfigsCount, ppTestConfigs, pnTestConfigsCount, pOutBestConfig, pfnCallBack, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_TCHAR L_FAR * pszWorkingFolder; | /* working folder path */
L_UINT uFlags; | /* option flags */
L_INT nBitsPerPixel; | /* bits per pixel */
L_INT nBufferIteration; | /* buffer iteration count */
pFASTCONFIG pInFastConfigs; | /* pointer to a structure */
L_INT nInFastConfigsCount; | /* number of array elements */
pFASTCONFIG *ppTestConfigs; | /* pointer to a pointer to a structure */
L_INT *pnTestConfigsCount; | /* number of scan configurations tested */
pFASTCONFIG pOutBestConfig; | /* pointer to a structure */
L_UINT uStructSize; | /* size in bytes, of the structure pointed to by pltProperties */
LTWAINFINDFASTCONFIG pfnCallBack; | /* optional callback function */
L_VOID *pUserData; | /* pointer to more parameters for the callback */

Determines the best scanner configuration. This function is available in the Document/Medical Toolkits.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pszWorkingFolder | Character string containing the path to the working folder in which to save the tested images.
uFlags | Flags that control the display of the user interface and the actions of the function. Possible values are:
 | Value | Meaning
 | 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_USE_THREAD_MODE | [0x0008] Use the fast Thread mode.
 | LTWAIN_CHECK_ALL_DEFAULT_BPP | [0x0010] Test all supported BPP.
 | LTWAIN_KEEPOPEN | [0x0020] Keep the TWAIN data source open after scanning.
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.
nBufferIteration | This value is used to determine the number of memory configurations that will be tested. The maximum value for this parameter is 10.
pInFastConfigs | Pointer to a FASTCONFIG structure that contains an array of scan configurations to be tested. Pass NULL to test the default scan configurations
nInFastConfigsCount | Number of scan configurations referenced in pInFastConfigs. Pass 0 to test the default scan configurations.
ppTestConfigs | Address of a pointer to a FASTCONFIG structure. The function will automatically allocate an array of FASTCONFIG structures using the total number of tested configurations.
pnTestConfigsCount | Pointer to an integer variable to be updated with number of tested configurations.
pOutBestConfig | Pointer to a FASTCONFIG structure to be updated with the best configuration for the scanner.
uStructSize | Size in bytes, of the structure pointed to by pltProperties, for versioning. Use sizeof(FASTCONFIG).
pfnCallBack | Optional callback function, called for each scan configuration as it is tested.
 | If you do not provide a callback function, use NULL as the value of this parameter. No error reporting will occur.
 | If you do provide a callback function, use the function pointer as the value of this parameter.
 | The callback function must adhere to the function prototype described in the LTWAINFINDFASTCONFIG function.
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

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

This function will test scan configurations for the scanner selected by calling L_TwainSelectSource. It will update the pOutBestConfig parameter with the best scan configuration tested. Once the best scan configuration has been determined, the scan configuration's values for the transfer mode, bits per pixel, format and buffer size can be passed to L_TwainAcquireMulti so the images can be scanned as fast as possible.

To test user-defined/custom configurations, pass these configurations in pInFastConfigs and the number of configurations in nInFastConfigsCount.

To test the default configurations available for the Twain driver, pass NULL for pInFastConfigs and 0 for nInFastConfigsCount. In this case, the function will test scan configurations based the values passed in the nBitsPerPixel and nBufferIteration parameters.

The list of default scan configurations to test can be shortened by using the L_TwainGetScanConfigs function to get a list of default scan configurations based on transfer mode, bits per pixel and number of buffers. This list can then be passed to L_TwainFindFastConfig function to determine the best and fastest scan configuration.

If LTWAIN_CHECK_ALL_DEFAULT_BPP is set in uFlags then the function will test all supported bits per pixel for the selected scanner. If this flag is not set in uFlags, then the function will use the iBitsPerPixel parameter value.

If LTWAIN_USE_THREAD_MODE is set in uFlags, then the image acquisition process will run in thread mode. In some scanners, acquiring images in thread will improve the speed at which the image(s) is(are) acquired. In other scanners, high-speed scanners, for example, acquiring the image(s) in thread mode will provide little to no improvement in the speed at which the image(s) is(are) acquired.

The nBitsPerPixel parameter and LTWAIN_CHECK_ALL_DEFAULT_BPP flag will be used only if the transfer mode for the scan configuration being tested is LTWAIN_BUFFER_MODE or LTWAIN_NATIVE_MODE.

The nBufferIteration parameter will be used only if the transfer mode for the scan configuration being tested is LTWAIN_BUFFER_MODE.

If a valid callback function is passed for pfnCallBack, the scan configuration testing process can be stopped by returning any value other than SUCCESS for the callback function. The testing process is continued by returning SUCCESS for the callback function.

This function allocates storage for the array of scan configurations in ppTestConfigs. When this storage is no longer needed, you must free the storage by calling L_TwainFreeScanConfig.

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: | L_TwainAcquire, L_TwainAcquireList, L_TwainInitSession, L_TwainEndSession, L_TwainOpenTemplateFile, L_TwainCloseTemplateFile, L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetNumofCapsInFile, L_TwainGetCapabilityFromFile, L_TwainAcquireMulti, L_TwainGetScanConfigs, L_TwainFreeScanConfig.
Topics: | Fast TWAIN (Scan Configurations)
 | TWAIN Functionality: Fast TWAIN (Scan Configuration) Functions.

Example

For complete sample, refer to TWNCONFIG demo.

L_INT EXT_CALLBACK TwnScanConfig(HTWAINSESSION hSession, pFASTCONFIG pResConfig, L_VOID *pUserData)
{
L_TCHAR szBuffer[MAX_PATH];
if (pResConfig->bSuccess)
{
memset(szBuffer, 0, sizeof(szBuffer));
wsprintf(szBuffer, TEXT("Transfer Mode = %d\nFile Format = %d\nBuffer Size = %d\nRequired Time = %d\n"),
pResConfig->uTransferMode,
pResConfig->nFileFormat,
pResConfig->ulBufferSize,
pResConfig->uTime);

MessageBox(NULL, szBuffer, TEXT("Result Scan Configuration..."), MB_OK);
}
else
MessageBox(NULL, TEXT("The tested configuration failed…"), TEXT("Error!"), MB_OK);
return SUCCESS;
}

L_INT TestScanConfig(HWND hWnd, HTWAINSESSION hSession)
{
L_INT       nRet;
pFASTCONFIG pTestConfigs = NULL;
L_INT       nTestConfigsCount = 0;
pFASTCONFIG pFastConfig=NULL;
L_INT       nFastConfigCount;
FASTCONFIG  BestConfig;
L_TCHAR      szBuffer[MAX_PATH];

nRet = L_TwainGetScanConfigs (hSession, 1, LTWAIN_BUFFER_MODE, 5, &pFastConfig, sizeof(FASTCONFIG),
 &nFastConfigCount);
if (nRet != SUCCESS)
{
MessageBox(hWnd, TEXT("Error occurred while getting the scan configurations for the Memory transfer mode!!!"), TEXT("Error!!!"), MB_OK);
return nRet;
}

memset(&BestConfig, 0, sizeof(FASTCONFIG));

nRet = L_TwainFindFastConfig(hSession,
TEXT("c:\\TWAIN"),
LTWAIN_SHOW_USER_INTERFACE,
1,
5,
pFastConfig, nFastConfigCount,
&pTestConfigs,
&nTestConfigsCount,
&BestConfig,
sizeof(FASTCONFIG),
TwnScanConfig, NULL);

if (nRet == SUCCESS)
{
MessageBox(hWnd, TEXT("L_TwainFindFastConfig function was successful."), TEXT( "Notice"), MB_OK);

memset(szBuffer, 0, sizeof(szBuffer));
wsprintf(szBuffer, TEXT("Transfer Mode = %d\nFile Format = %d\nBuffer Size = %d\nRequired Time = %d\n"),
BestConfig.uTransferMode,
BestConfig.nFileFormat,
BestConfig.ulBufferSize,
BestConfig.uTime);

MessageBox(hWnd, szBuffer, TEXT("Best Scan Configuration..."), MB_OK);

L_TwainFreeScanConfig (hSession, &pTestConfigs, nTestConfigsCount);
}
else
MessageBox(hWnd, TEXT("Error occurred in the L_TwainFindFastConfig function!!!"), TEXT("Error!!!"), MB_OK);

L_TwainFreeScanConfig(hSession, &pFastConfig, nFastConfigCount);
return nRet;
}


L_TwainFreeContainer

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainFreeContainer (pCapability)

TW_CAPABILITY * pCapability;

/* pointer to a structure */

Frees the container of the specified structure.

Parameter | Description
pCapability | Pointer to a structure that contains the capability container to free.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

The container in the TW_CAPABILITY structure will be internally freed.

This is a container that was allocated by one of the following functions:

L_TwainCreateNumericContainerOneValue

L_TwainCreateNumericContainerArray

L_TwainCreateNumericContainerEnum

L_TwainCreateNumericContainerRange

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: | L_TwainCreateNumericContainerOneValue, L_TwainCreateNumericContainerArray, L_TwainCreateNumericContainerEnum, L_TwainCreateNumericContainerRange.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

For an example, refer to L_TwainAcquire.


L_TwainFreeExtendedImageInfoStructure

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainFreeExtendedImageInfoStructure (pptwExtImgInfo)

TW_EXTIMAGEINFO ** pptwExtImgInfo;

/* pointer to a pointer to a structure*/

Frees the TW_EXTIMAGEINFO structure.

Parameter | Description
pptwExtImgInfo | Pointer to a pointer to the TW_EXTIMAGEINFO structure to be freed.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

This function will free the TW_EXTIMAGEINFO structure allocated by the L_TwainGetExtendedImageInfo function.

For more information on extended image information, refer to the Twain 1.9 Specification, available at www.twain.org.

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: | L_TwainGetExtendedImageInfo.
Topics: | How to Acquire from the TWAIN Source
 | TWAIN Functionality: Extended Image Information Functions.

Example

For an example, refer to L_TwainGetExtendedImageInfo.


L_TwainFreePropQueryStructure

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainFreePropQueryStructure (ppltProperty)

pLTWAINPROPERTYQUERY * ppltProperty;

/* pointer to a pointer to a structure */

Frees the pointer to the specified structure.

Parameter | Description
ppltProperty | Pointer to a pointer to a LTWAINPROPERTYQUERY structure to free.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

ppltProperty parameter was allocated by the calling the L_TwainQueryProperty function.

The ppltProperty parameter will be internally freed.

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: | L_TwainQueryProperty.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Property Functions.

Example

For an example, refer to L_TwainQueryProperty.


L_TwainFreeScanConfig

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainFreeScanConfig(hSession, ppFastConfig, nFastConfigCount)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pFASTCONFIG *ppFastConfig; | /* address of a pointer to a FASTCONFIG structure */
L_INT nFastConfigCount; | /* number of array elements */

Frees storage allocated for a scan configuration array. This function is available in the Document/Medical Toolkits.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
ppFastConfig | Address of the pointer to the array of FASTCONFIG structures. This function will free the array of FASTCONFIG structures allocated by L_TwainFindFastConfig and L_TwainGetScanConfigs.
nFastConfigCount | Number of array elements to free.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Call this function to free the memory allocated by the L_TwainFindFastConfig and L_TwainGetScanConfigs functions.

This function should be called when your program no longer needs the array of FASTCONFIG structures.

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: | L_TwainAcquire, L_TwainAcquireList, L_TwainInitSession, L_TwainEndSession, L_TwainOpenTemplateFile, L_TwainCloseTemplateFile, L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetNumofCapsInFile, L_TwainGetCapabilityFromFile, L_TwainAcquireMulti, L_TwainFindFastConfig, L_TwainGetScanConfigs
Topics: | Fast TWAIN (Scan Configurations)
 | TWAIN Functionality: Fast TWAIN (Scan Configuration) Functions.

Example

For a complete sample, refer to the TWNCONFIG demo.

For an example, refer to L_TwainFindFastConfig.


L_TwainGetAcquirePageOptions

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetAcquirePageOptions(hSession, pnPaperSize, pnPaperDirection)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_INT * pnPaperSize; | /* pointer to a variable */
L_INT * pnPaperDirection; | /* pointer to a variable */

Gets the current page size, and page orientation values used when transferring images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pnPaperSize | Pointer to a variable to be updated with the page size. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).
pnPaperDirection | Pointer to a variable to be updated with the page direction. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

Returns

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

Comments

This function gets the current page size capability ICAP_SUPPORTEDSIZES, and page orientation capability ICAP_ORIENTATION values. For more information on these capabilities, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To set these capabilities, call the L_TwainSetAcquirePageOptions function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainGetImageEffects.


L_TwainGetCapability

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetCapability (hSession, pCapability, uFlags)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_CAPABILITY pCapability; | /* pointer to a structure */
L_UINT uFlags; | /* optional flags */

Gets the specified capability value(s).

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pCapability | Pointer to a TW_CAPABILITY structure that references the required capability. This structure must be allocated and it will be filled with data corresponding to the required capability to get.
uFlags | Flags that indicate the capability values to get. Possible values are:
 | Value | Meaning
 | LTWAIN_CAPABILITY_GETCURRENT | [3] Get the current value.
 | LTWAIN_CAPABILITY_GETDEFAULT | [4] Get the default value.
 | LTWAIN_CAPABILITY_GETVALUES | [5] Get all available values.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

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

Function: | L_TwainStartCapsNeg, L_TwainEndCapsNeg, L_TwainSetProperties, L_TwainGetProperties, L_TwainSetCapability, L_TwainInitSession, L_TwainEndSession.
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions.

Example

L_INT nRet;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap = ICAP_XFERMECH;
twCap.ConType = TWON_DONTCARE16;
nRet = L_TwainGetCapability (g_hSession, &twCap, LTWAIN_CAPABILITY_GETCURRENT);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability"), TEXT("ERROR"), MB_OK);
return;
}
L_TwainFreeContainer(&twCap);


L_TwainGetCapabilityFromFile

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetCapabilityFromFile (hSession, hFile, pptwCapability, uIndex)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
HTWAINTEMPLATEFILE hFile; | /* handle to an existing template file */
pTW_CAPABILITY * pptwCapability; | /* pointer to a pointer to a structure */
L_UINT uIndex; | /* capability index */

Gets the capability, at the specified index, in the specified file.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
hFile | Handle to an existing template file.
pptwCapability | Pointer to a pointer to a TW_CAPABILITY structure. This structure will be allocated internally.
uIndex | Index of the capability to get from the file. This is a zero-based index.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

To get a capability stored in a file; the file must be opened for reading by calling L_TwainOpenTemplateFile function. The user must declare a variable of type pTW_CAPABILITY and pass the address of this to the function. This parameter will be updated with a pointer to the capability at the specified index.

Note:

If the function is successful, the user must:

Free the container of the TW_CAPABILITY structure by a calling L_TwainFreeContainer function.

Free the value referenced by the contents of the pptwCapability using GlobalUnlock and GlobalFree.

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: | L_TwainOpenTemplateFile, L_TwainAddCapabilityToFile, L_TwainTemplateDlg, L_TwainGetNumOfCapsInFile, L_TwainCloseTemplateFile, L_TwainInitSession, L_TwainEndSession.
Topics: | Handling Template Files
 | TWAIN Functionality: Capability Functions.

Example

HTWAINSESSION g_hSession;
OPENFILENAME ofn;
L_INT nRet;
HTWAINTEMPLATEFILE hFile;
L_TCHAR szFilePath [MAX_PATH];
HWND hDlg; // Parent dialog handle

memset (&ofn, 0, sizeof(OPENFILENAME));
memset (szFilePath, 0, MAX_PATH);

ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hDlg;
ofn.lpstrFile = szFilePath;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrTitle = TEXT("Load Template File");

if (GetOpenFileName (&ofn))
{
nRet = L_TwainOpenTemplateFile (g_hSession, &hFile, szFilePath, LTWAIN_TEMPLATE_OPEN_READ);

if (nRet == SUCCESS)
{
L_UINT uIndex, uCapCount = 0;
pTW_CAPABILITY ptwCapability = NULL;
nRet = L_TwainGetNumOfCapsInFile (g_hSession, hFile, &uCapCount);

if (nRet == SUCCESS)
{
for (uIndex = 0 ; uIndex < uCapCount ; uIndex ++)
{
nRet = L_TwainGetCapabilityFromFile (g_hSession, hFile, &ptwCapability, uIndex);

if (nRet == SUCCESS)
{
nRet = L_TwainSetCapability (g_hSession, ptwCapability, LTWAIN_CAPABILITY_SET);
}

if (ptwCapability)
{
GlobalFree (ptwCapability->hContainer);
GlobalUnlock(ptwCapability);
GlobalFree (ptwCapability);
}
}
}
L_TwainCloseTemplateFile (g_hSession, hFile);
}
}


L_TwainGetDuplexOptions

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetDuplexOptions(hSession, pbEnableDuplex, pnDuplexMode)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_BOOL * pbEnableDuplex; | /* pointer to a variable to be updated */
L_INT * pnDuplexMode; | /* pointer to the duplex mode */

Gets the current duplex mode and the enabled status of the current duplex mode for the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pbEnableDuplex | Pointer to a variable to be updated with a value that specifies whether the duplex mode is enabled or disabled. Possible values are:
 | Value | Meaning
 | TRUE | Duplex mode is enabled.
 | FALSE | Duplex mode is disabled.
pnDuplexMode | Pointer to a variable to be updated with the duplex mode value.

Returns

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

Comments

This function gets the current duplex mode capability CAP_DUPLEX, and the duplex mode's enabled status capability CAP_DUPLEXENABLED values. For more information on these capabilities, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To set these capabilities, call the L_TwainEnableDuplex function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainEnableDuplex.


L_TwainGetExtendedImageInfo

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetExtendedImageInfo(hSession, ptwExtImgInfo)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
TW_EXTIMAGEINFO * ptwExtImgInfo; | /* pointer to a structure */

Gets the extended image information related to the image acquired by the L_TwainAcquire function.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
ptwExtImgInfo | Pointer to a TW_EXTIMAGEINFO structure that references extended image info to fill.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

This function can only be called during the LTWAINBITMAPCALLBACK callback function, called by the L_TwainAcquire function, and only after a page has been acquired from a TWAIN source.

Extended image information can be Barcode texts, Barcode data, etc. For more information on extended image information, refer to the Twain 1.9 Specification, available at www.twain.org.

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: | L_TwainAcquire, LTWAINBITMAPCALLBACK, L_TwainInitSession, L_TwainEndSession.
Topics: | How to Acquire from the TWAIN Source
 | TWAIN Functionality: Extended Image Information Functions.

Example

// This function can be passed as the callback to L_TwainAcquire function
L_INT TwainAcquireCB (HTWAINSESSION hSession, pBITMAPHANDLE pBitmap, L_VOID * pUserData)
{
L_INT nRet = SUCCESS;
TW_EXTIMAGEINFO * pExtImg = NULL;

pExtImg = (TW_EXTIMAGEINFO *)GlobalAllocPtr (GHND, sizeof (TW_EXTIMAGEINFO) + sizeof(TW_INFO));
if (pExtImg)
{
pExtImg->NumInfos = 2;
pExtImg->Info[1].InfoID = TWEI_BARCODECOUNT;
pExtImg->Info[1].ItemType = TWTY_UINT32;
pExtImg->Info[1].InfoID = TWEI_BARCODETYPE;
pExtImg->Info[1].ItemType = TWTY_UINT32;

if (L_TwainGetExtendedImageInfo (hSession, pExtImg) == SUCCESS)
{
// Do processing to returned values
L_TwainFreeExtendedImageInfoStructure (&pExtImg);
}

GlobalFreePtr (pExtImg);
}

return nRet;
}


L_TwainGetImageBitsPerPixel

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetImageBitsPerPixel(hSession, pnBitsPerPixel)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_INT * pnBitsPerPixel; | /* pointer to the bits per pixel */

Gets the current bits per pixel value used when transferring images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pnBitsPerPixel | Pointer to a variable to be updated with the number of bits per pixel. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

Returns

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

Comments

This function gets the bits per pixel capability ICAP_BITDEPTH. For more information on this capability, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To set the bits per pixel capability, call the L_TwainSetImageBitsPerPixel function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainSetImageUnit.


L_TwainGetImageEffects

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetImageEffects(hSession, ulFlags, pBrightness, pContrast, pHighlight)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_UINT32 ulFlags; | /* optional flags */
pTW_FIX32 pBrightness; | /* pointer to a variable */
pTW_FIX32 pContrast; | /* pointer to a variable */
pTW_FIX32 pHighlight; | /* pointer to a variable */

Gets the current brightness, highlight and contrast values used when transferring images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
ulFlags | Flags that indicate which capability values to get. Possible values are:
 | Value | Meaning
 | TWAIN_NEGOTIATE_BRIGHTNESS | [0x0010] Gets the brightness capability value.
 | TWAIN_NEGOTIATE_CONTRAST | [0x0020] Gets the contrast capability value.
 | TWAIN_NEGOTIATE_HIGHLIGHT | [0x0040] Gets the highlight capability value.
pBrightness | Pointer to a variable to be updated with the current brightness capability value. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).
pContrast | Pointer to a variable to be updated with the current contrast capability value. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).
pHighlight | Pointer to a variable to be updated with the current highlight capability value. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

Returns

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

Comments

This function gets the current brightness capability ICAP_BRIGHTNESS, highlight capability ICAP_HIGHLIGHT, and contrast capability ICAP_CONTRAST values. For more information on these capabilities, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To set these capabilities, call L_TwainSetImageEffects function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainSetImageEffects.


L_TwainGetImageFrame

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetImageFrame(hSession, pFrame)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_FRAME pFrame; | /* pointer to a structure */

Gets the current image frame used to transfer images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pFrame | Pointer to a structure to be updated with the current image frame.

Returns

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

Comments

The image frame specifies the size and location of the image to acquire. To set the image frame for the current TWAIN source, call the L_TwainSetImageFrame function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainSetImageFrame.


L_TwainGetImageUnit

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetImageUnit (hSession, pnUnit)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_INT * pnUnit; | /* pointer to a variable */

Gets the current image unit value used when transferring images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pnUnit | Pointer to a variable to be updated with the current image unit value. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

Returns

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

Comments

This function gets the value of the image unit capability ICAP_UNITS. For more information on this capability, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To set the image unit capability value, call the L_TwainSetImageUnit function

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainSetImageUnit.


L_TwainGetJPEGCompression

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetJPEGCompression(hSession, pTwJpegComp, uFlag)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_JPEGCOMPRESSION pTwJpegComp; | /* pointer to a structure */
L_UINT uFlag; | /* flags */

Gets the current or default JPEG compression settings for the session.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pTwJpegComp | Pointer to a TW_JPEGCOMPRESSION structure that contains the JPEG compression settings.
uFlag | Flag that indicates which type of JPEG compression values to get. Possible values are:
 | Value | Meaning
 | LTWAIN_GET_JPEG_COMPRESSION | [0x0001] Get the current JPEG compression settings
 | LTWAIN_GET_DEFAULT_JPEG_COMPRESSION | [0x0002] Get the default JPEG compression settings

Returns

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

Comments

This function will get the current or default TWAIN JPEG compression settings, depending on the flag passed to the uFlag parameter.

For more information about TW_JPEGCOMPRESSION, refer to the TWAIN 1.9 specification from the site "http://www.twain.org/".

This function must be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetJPEGCompression, L_TwainInitSession, L_TwainStartCapsNeg
Topics: | Using JPEG compression for a TWAIN source

Example

void TestJPEGCompression(HTWAINSESSION hSession)
{
L_TwainStartCapsNeg (hSession);

TW_JPEGCOMPRESSION myJPEG;
memset(&myJPEG, 0, sizeof(TW_JPEGCOMPRESSION));
L_INT nRet = L_TwainGetJPEGCompression(hSession, &myJPEG, LTWAIN_GET_JPEG_COMPRESSION);
if (nRet == SUCCESS)
{
myJPEG.ColorSpace = TWPT_GRAY;
myJPEG.SubSampling = 0x10001000;
myJPEG.NumComponents = 1;
myJPEG.RestartFrequency = 0;
myJPEG.QuantMap[0] = 0;
memset(&myJPEG.QuantTable[0], 0, sizeof(TW_MEMORY));
myJPEG.HuffmanMap[0] = 0;
memset(&myJPEG.HuffmanDC[0], 0, sizeof(TW_MEMORY));
memset(&myJPEG.HuffmanAC[0], 0, sizeof(TW_MEMORY));

nRet = L_TwainSetJPEGCompression (hSession, &myJPEG, LTWAIN_SET_JPEG_COMPRESSION);
if (nRet == SUCCESS)
MessageBox(NULL, TEXT("Setting JPEG compression options was successful"), ("Notice!"), MB_OK);
}

L_TwainEndCapsNeg(hSession);
}


L_TwainGetMaxXferCount

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetMaxXferCount(hSession, pnMaxXferCount)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_INT * pnMaxXferCount; | /* pointer to the transfer image count */

Gets the maximum number of images that can be transferred from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pnMaxXferCount | Pointer to a variable to be updated with the maximum number of images that can be transferred from the current TWAIN source.

Returns

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

Comments

This function gets the current maximum transfer count capability CAP_XFERCOUNT value. For more information on these capabilities, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To set the maximum transfer count capability call L_TwainSetMaxXferCount function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainEnableDuplex.


L_TwainGetNumericContainerBOOLValue

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetNumericContainerBOOLValue(pCapability, nIndex, pbValue)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
L_INT nIndex; | /* value’s index */
L_BOOL *pbValue; | /* pointer to a Boolean value */

Gets the specified value from a container.

Parameter | Description
pCapability | Pointer to a TW_CAPABILITY structure that references the container value to get.
nIndex | Index of the value to get. Possible values are:
 | Value | Meaning
 | LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this function will return an error code.
 | LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | >= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the function will return an error code.
pbValue | Reference to a Boolean value to be updated with the specified container value.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Use this function to get a value from a container's item list when the item list type is Boolean.

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: | L_TwainGetNumericContainerItemType, L_TwainGetNumericContainerINTValue, L_TwainGetNumericContainerUINTValue, L_TwainGetNumericContainerFIX32Value, L_TwainGetNumericContainerFRAMEValue, L_TwainGetNumericContainerSTRINGValue, L_TwainGetNumericContainerUNICODEValue.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

L_INT nRet;
L_INT nItemType;
L_BOOL bValue;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap = CAP_AUTOFEED;
twCap.ConType = TWON_ONEVALUE;
nRet = L_TwainGetCapability(g_hSession, &twCap, LTWAIN_CAPABILITY_GETCURRENT);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability"), TEXT("ERROR"), MB_OK);
return;
}

nRet = L_TwainGetNumericContainerItemType(&twCap, &nItemType);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability item type"), TEXT("ERROR"), MB_OK);
}
else if (nItemType == TWTY_BOOL)
{
nRet = L_TwainGetNumericContainerBOOLValue (&twCap, 0, &bValue);
if (nRet != SUCCESS)
MessageBox (NULL, TEXT("Failed to get capability item value"), TEXT("ERROR"), MB_OK);
}


L_TwainGetNumericContainerFIX32Value

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetNumericContainerFIX32Value(pCapability, nIndex, ptwFix)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
L_INT nIndex; | /* value's index */
TW_FIX32 *ptwFix; | /* pointer to a TW_FIX32 structure */

Gets the specified value from a container.

Parameter | Description
pCapability | Pointer to a TW_CAPABILITY structure that references the container value to get.
nIndex | Index of the value to get. Possible values are:
 | Value | Meaning
 | LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this function will return an error code.
 | LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | >= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the function will return an error code.
ptwFix | Pointer to a TW_FIX32 value to be updated with the specified container value.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Use this function to get a value from a container's item list when the item list type is TW_FIX32.

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: | L_TwainGetNumericContainerItemType, L_TwainGetNumericContainerINTValue, L_TwainGetNumericContainerUINTValue, L_TwainGetNumericContainerBOOLValue, L_TwainGetNumericContainerFRAMEValue, L_TwainGetNumericContainerSTRINGValue, L_TwainGetNumericContainerUNICODEValue.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

L_INT nRet;
L_INT nItemType;
TW_FIX32 twFix;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap = ICAP_BRIGHTNESS;
twCap.ConType = TWON_ONEVALUE;
nRet = L_TwainGetCapability(g_hSession, &twCap, LTWAIN_CAPABILITY_GETCURRENT);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability"), TEXT("ERROR"), MB_OK);
return;
}

nRet = L_TwainGetNumericContainerItemType(&twCap, &nItemType);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability item type"), TEXT("ERROR"), MB_OK);
}
else if (nItemType == TWTY_BOOL)
{
nRet = L_TwainGetNumericContainerFIX32Value (&twCap, 0, &twFix);
if (nRet != SUCCESS)
MessageBox (NULL, TEXT("Failed to get capability item value"), TEXT("ERROR"), MB_OK);
}


L_TwainGetNumericContainerFRAMEValue

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetNumericContainerFRAMEValue(pCapability, nIndex, ptwFrame)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
L_INT nIndex; | /* value's index */
TW_FRAME *ptwFrame; | /* pointer to a TW_FRAME value */

Gets the specified value from a container.

Parameter | Description
pCapability | Pointer to a TW_CAPABILITY structure that references the container value to get.
nIndex | Index of the value to get. Possible values are:
 | Value | Meaning
 | LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this function will return an error code.
 | LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | >= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the function will return an error code.
twFrame | Reference to a TW_FRAME value to be updated with the specified container value.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Use this function to get a value from a container's item list when the item list type is TW_FRAME.

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: | L_TwainGetNumericContainerItemType, L_TwainGetNumericContainerINTValue, L_TwainGetNumericContainerUINTValue, L_TwainGetNumericContainerBOOLValue, L_TwainGetNumericContainerFIX32Value, L_TwainGetNumericContainerSTRINGValue, L_TwainGetNumericContainerUNICODEValue.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

L_INT nRet;
L_INT nItemType;
TW_FRAME twFrame;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap = ICAP_FRAMES;
twCap.ConType = TWON_ONEVALUE;
nRet = L_TwainGetCapability(g_hSession, &twCap, LTWAIN_CAPABILITY_GETCURRENT);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability"), TEXT("ERROR"), MB_OK);
return;
}

nRet = L_TwainGetNumericContainerItemType(&twCap, &nItemType);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability item type"), TEXT("ERROR"), MB_OK);
}
else if (nItemType == TWTY_BOOL)
{
nRet = L_TwainGetNumericContainerFRAMEValue (&twCap, 0, &twFrame);
if (nRet != SUCCESS)
MessageBox (NULL, TEXT("Failed to get capability item value"), TEXT("ERROR"), MB_OK);
}


L_TwainGetNumericContainerINTValue

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetNumericContainerINTValue(pCapability, nIndex, pnValue)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
L_INT nIndex; | /* value's index */
L_INT *pnValue; | /* pointer to an integer value */

Gets the specified value from a container.

Parameter | Description
pCapability | Pointer to a TW_CAPABILITY structure that references the container value to get.
nIndex | Index of the value to get. Possible values are:
 | Value | Meaning
 | LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this function will return an error code.
 | LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | >= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the function will return an error code.
pnValue | Pointer to an integer value to be updated with the specified container value.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Use this function to get a value from a container's item list when the item list type is integer.

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: | L_TwainGetNumericContainerItemType, L_TwainGetNumericContainerUINTValue, L_TwainGetNumericContainerBOOLValue, L_TwainGetNumericContainerFIX32Value, L_TwainGetNumericContainerFRAMEValue, L_TwainGetNumericContainerSTRINGValue, L_TwainGetNumericContainerUNICODEValue.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

L_INT nRet;
L_INT nItemType, nValue;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap = CAP_XFERCOUNT;
twCap.ConType = TWON_ONEVALUE;
nRet = L_TwainGetCapability(g_hSession, &twCap, LTWAIN_CAPABILITY_GETCURRENT);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability"), TEXT("ERROR"), MB_OK);
return;
}

nRet = L_TwainGetNumericContainerItemType(&twCap, &nItemType);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability item type"), TEXT("ERROR"), MB_OK);
}
else if (nItemType == TWTY_INT16)
{
nRet = L_TwainGetNumericContainerINTValue (&twCap, 0, &nValue);
if (nRet != SUCCESS)
MessageBox (NULL, TEXT("Failed to get capability item value"), TEXT("ERROR"), MB_OK);
}


L_TwainGetNumericContainerItemType

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetNumericContainerItemType(pCapability, pnItemType)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
L_INT *pnItemType; | /* container type */

Gets the item type of the container of the specified capability.

Parameter | Description
pCapability | Pointer to a TW_CAPABILITY structure. The nItemType parameter will be updated with the item type of this structure's container.
pnItemType | Pointer to an integer to be updated with the container's item type.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

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: | L_TwainGetNumericContainerINTValue, L_TwainGetNumericContainerUINTValue, L_TwainGetNumericContainerBOOLValue, L_TwainGetNumericContainerFIX32Value, L_TwainGetNumericContainerFRAMEValue, L_TwainGetNumericContainerSTRINGValue, L_TwainGetNumericContainerUNICODEValue.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

For an example, refer to L_TwainGetNumericContainerUINTValue.


L_TwainGetNumericContainerSTRINGValue

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetNumericContainerSTRINGValue(pCapability, nIndex, twString)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
L_INT nIndex; | /* value's index */
TW_STR1024 twString; | /* reference to a TW_STR1024 value */

Gets the specified value from a container.

Parameter | Description
pCapability | Pointer to a TW_CAPABILITY structure that references the container value to get.
nIndex | Index of the value to get. Possible values are:
 | Value | Meaning
 | LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this function will return an error code.
 | LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | >= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the function will return an error code.
twString | A TW_STR1024 value to be updated with the specified container value.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Use this function to get a value from a container's item list when the item list type is TW_STR1024.

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: | L_TwainGetNumericContainerItemType, L_TwainGetNumericContainerINTValue, L_TwainGetNumericContainerUINTValue, L_TwainGetNumericContainerBOOLValue, L_TwainGetNumericContainerFIX32Value, L_TwainGetNumericContainerFRAMEValue, L_TwainGetNumericContainerUNICODEValue.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

L_INT nRet;
L_INT nItemType;
TW_STR1024 twString;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap = ICAP_HALFTONES;
twCap.ConType = TWON_ONEVALUE;
nRet = L_TwainGetCapability(g_hSession, &twCap, LTWAIN_CAPABILITY_GETCURRENT);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability"), TEXT("ERROR"), MB_OK);
return;
}

nRet = L_TwainGetNumericContainerItemType(&twCap, &nItemType);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability item type"), TEXT("ERROR"), MB_OK);
}
else if (nItemType == TWTY_BOOL)
{
nRet = L_TwainGetNumericContainerSTRINGValue (&twCap, 0, twString);
if (nRet != SUCCESS)
MessageBox (NULL, TEXT("Failed to get capability item value"), TEXT("ERROR"), MB_OK);
}


L_TwainGetNumericContainerUINTValue

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetNumericContainerUINTValue(pCapability, nIndex, puValue)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
L_INT nIndex; | /* value's index */
L_UINT *puValue; | /* pointer to an integer value */

Gets the specified value from a container.

Parameter | Description
pCapability | Pointer to a TW_CAPABILITY structure that references the container value to get.
nIndex | Index of the value to get. Possible values are:
 | Value | Meaning
 | LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this function will return an error code.
 | LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | >= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the function will return an error code.
puValue | Pointer to an unsigned integer value to be updated with the specified container value.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Use this function to get a value from a container's item list when the item list type is unsigned integer.

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: | L_TwainGetNumericContainerItemType, L_TwainGetNumericContainerINTValue, L_TwainGetNumericContainerBOOLValue, L_TwainGetNumericContainerFIX32Value, L_TwainGetNumericContainerFRAMEValue, L_TwainGetNumericContainerSTRINGValue, L_TwainGetNumericContainerUNICODEValue.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

L_INT nRet;
L_INT nItemType;
L_UINT uValue;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap = ICAP_UNITS;
twCap.ConType = TWON_ONEVALUE;
nRet = L_TwainGetCapability(g_hSession, &twCap, LTWAIN_CAPABILITY_GETCURRENT);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability"), TEXT("ERROR"), MB_OK);
return;
}

nRet = L_TwainGetNumericContainerItemType(&twCap, &nItemType);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability item type"), TEXT("ERROR"), MB_OK);
}
else if (nItemType == TWTY_BOOL)
{
nRet = L_TwainGetNumericContainerUINTValue (&twCap, 0, &uValue);
if (nRet != SUCCESS)
MessageBox (NULL, TEXT("Failed to get capability item value"), TEXT("ERROR"), MB_OK);
}


L_TwainGetNumericContainerUNICODEValue

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetNumericContainerUNICODEValue(pCapability, nIndex, twUniCode)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
L_INT nIndex; | /* value's index */
TW_UNI512 twUniCode; | /* reference to a TW_UNI512 value */

Gets the specified value from a container.

Parameter | Description
pCapability | Pointer to a TW_CAPABILITY structure that references the container value to get.
nIndex | Index of the value to get. Possible values are:
 | Value | Meaning
 | LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this function will return an error code.
 | LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | >= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the function will return an error code.
twUniCode | A TW_UNI512 value to be updated with the specified container value.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Use this function to get a value from a container's item list when the item list type is TW_UNI512.

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: | L_TwainGetNumericContainerItemType, L_TwainGetNumericContainerINTValue, L_TwainGetNumericContainerUINTValue, L_TwainGetNumericContainerBOOLValue, L_TwainGetNumericContainerFIX32Value, L_TwainGetNumericContainerFRAMEValue, L_TwainGetNumericContainerSTRINGValue.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

For an example, refer to L_TwainGetNumericContainerItemType.


L_TwainGetNumericContainerValue

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetNumericContainerValue (pCapability, nIndex, ppValue)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
L_INT nIndex; | /* value's index */
L_VOID ** ppValue; | /* variable to be allocated by the function */

Gets the specified value from a container.

Parameter | Description
pCapability | Pointer to a structure that contains the capability container value to get.
nIndex | Index of the value to get. Possible values are:
 | Value | Meaning
 | LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this function will return an error code.
 | LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppvalue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the function will return an error code.
 | >= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the function will return an error code.
ppValue | Variable to be allocated by the function and updated with the specified value. The user must free this value using the Windows APIs GlobalUnlock and GlobalFree functions.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

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: | L_TwainCreateNumericContainerOneValue, L_TwainCreateNumericContainerEnum, L_TwainCreateNumericContainerArray, L_TwainCreateNumericContainerRange, L_TwainFreeContainer.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

L_INT TwainGetCurrentValue()
{
L_INT nRet;
L_UINT16 * pVal = NULL;
TW_CAPABILITY twCap;

twCap.Cap = ICAP_XFERMECH;
twCap.ConType = TWON_DONTCARE16;
nRet = L_TwainGetCapability (g_hSession, &twCap, LTWAIN_CAPABILITY_GETCURRENT);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability"), TEXT("ERROR"), MB_OK);
return FAILURE;
}

if (twCap.ConType == TWON_ONEVALUE)
nRet = L_TwainGetNumericContainerValue (&twCap, 0, (L_VOID **)&pVal);
else
if (twCap.ConType == TWON_ONEVALUE)
nRet = L_TwainGetNumericContainerValue (&twCap, LTWAIN_VALUE_CURRENT, (L_VOID **)&pVal);

if (nRet != SUCCESS)
return nRet;

return SUCCESS;
}


L_TwainGetNumOfCapsInFile

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetNumOfCapsInFile (hSession, hFile, puCapCount)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
HTWAINTEMPLATEFILE hFile; | /* handle to an existing template file */
L_UINT *puCapCount; | /* pointer to a variable */

Gets the number of stored capabilities from the specified file.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
hFile | Handle to an existing template file.
puCapCount | Pointer to a variable to be updated with the number of capabilities in the specified file.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

The template file must be opened for reading by calling L_TwainOpenTemplateFile function.

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: | L_TwainOpenTemplateFile, L_TwainAddCapabilityToFile, L_TwainGetCapabilityFromFile, L_TwainTemplateDlg, L_TwainCloseTemplateFile, L_TwainInitSession.
Topics: | Handling Template Files
 | TWAIN Functionality: Capability Functions.

Example

For an example, refer to L_TwainGetCapabilityFromFile.


L_TwainGetProperties

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetProperties (hSession, pltProperties, uFlags)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pLTWAINPROPERTIES pltProperties; | /* pointer to a structure */
L_UINT uStructSize; | /* size in bytes, of the structure pointed to by pBitmap */
L_UINT uFlags; | /* optional flags */

Gets the current or default values of the properties defined in the LTWAINPROPERTIES structure.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pltProperties | Pointer to a LTWAINPROPERTIES structure to be updated with the current or default properties. This must be a valid pointer for an LTWAINPROPERTIES structure.
uStructSize | Size in bytes, of the structure pointed to by pltProperties, for versioning. Use sizeof(LTWAINPROPERTIES).
uFlags | Flag that indicates the property values to get. Possible values are:
 | Value | Meaning
 | LTWAIN_PROPERTIES_GETCURRENT | [3] Get the current values.
 | LTWAIN_PROPERTIES_GETDEFAULT | [4] Get the default values.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

This function must be called after L_TwainStartCapsNeg is called and before L_TwainEndCapsNeg is called.

This function lets the user get information on the properties contained in the LTWAINPROPERTIES structure. It is a high-level alternative to getting capabilities using the L_TwainGetCapability or L_TwainEnumCapabilities functions. For more information on getting and setting TWAIN capabilities, refer to Getting and Setting Capabilities.

To set properties, use the L_TwainSetProperties function.

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: | L_TwainStartCapsNeg, L_TwainEndCapsNeg, L_TwainSetProperties, L_TwainSetCapability, L_TwainGetCapability, L_TwainInitSession, L_TwainEndSession.
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Property Functions.

Example

L_INT EXT_CALLBACK PropSetCB (HTWAINSESSION hSession, L_UINT uCap, L_INT nStatus, L_VOID * pValue, L_VOID * pUserData)
{
// Do your error notification or place any other code here.

return SUCCESS;
}

// Function to change the transfer mode to file
HTWAINSESSION g_hSession;
L_INT TwainSetFileXferData ()
{
L_INT nRet;
LTWAINPROPERTIES twProps;

// Initialize to zero
memset (&twProps, 0, LTWAINPROPERTIESSIZE);

// Get the current properties of the selected twain source
nRet = L_TwainGetProperties (g_hSession, &twProps, sizeof(LTWAINPROPERTIES), LTWAIN_PROPERTIES_GETCURRENT);
if (nRet != SUCCESS)
return nRet;

// Change transfer mode to File
twProps.DataTransfer.nTransferMode = TWSX_FILE;
lstrcpy (twProps.DataTransfer.szFileName, TEXT("c:\\temp\\Twain.bmp"));
twProps.DataTransfer.nScanFileFormat = TWFF_BMP;

// Set the new properties
nRet = L_TwainSetProperties (g_hSession, &twProps, LTWAIN_PROPERTIES_SET, PropSetCB, NULL);
if (nRet != SUCCESS)
return nRet;

return SUCCESS;
}


L_TwainGetResolution

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetResolution(hSession, pXRes, pYRes)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_FIX32 pXRes; | /* pointer to a variable */
pTW_FIX32 pYRes; | /* pointer to a variable */

Gets the current horizontal and vertical resolution used to transfer images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pXRes | Pointer to a variable to be updated with the current horizontal resolution value.
pYres | Pointer to a variable to be updated with the current vertical resolution value.

Returns

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

Comments

This function gets the horizontal and vertical resolution capability values ICAP_XRESOLUTION and ICAP_YRESOLUTION. For more information on these capabilities, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To set the resolution values, call the L_TwainSetResolution function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainSetResolution.


L_TwainGetScanConfigs

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetScanConfigs(hSession, nBitsPerPixel, uTransferMode, nBufferIteration, ppFastConfig, uStructSize, pnFastConfigCount)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_INT nBitsPerPixel; | /* bits per pixel */
L_UINT uTransferMode; | /* transfer mode */
L_INT nBufferIteration; | /* buffer iteration */
pFASTCONFIG *ppFastConfig; | /* address of a pointer to the FASTCONFIG structure */
L_UINT uStructSize; | /* size in bytes, of the structure pointed to by ppFastConfig */
L_INT *pnFastConfigCount; | /* pointer to an integer */

Gets the default scan configurations for the given transfer mode, buffer iteration and bits per pixel. This function is available in the Document/Medical Toolkits.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
nBitsPerPixel | The number of bits per pixel for which to get the default scan configurations.
uTransferMode | Transfer mode for which to get the default scan configurations.
 | Value | Meaning
 | LTWAIN_FILE_MODE | [0x001] Use File transfer mode
 | LTWAIN_BUFFER_MODE | [0x002] Use Memory transfer mode
 | LTWAIN_NATIVE_MODE | [0x004] Use Native transfer mode
nBufferIteration | Number used to determine the number of memory configurations that will be tested. This function uses this number to determine which default scan configurations to get.
ppFastConfig | Address of a pointer to a FASTCONFIG structure. This function will automatically allocate an array of FASTCONFIG structures using the total number of scan configurations. This array will be updated with the scan configurations retrieved based on the specified bits per pixel, transfer mode and number of buffers.
uStructSize | Size in bytes, of the structure pointed to by ppFastConfig, for versioning. Use sizeof(FASTCONFIG).
pnFastConfigCount | Pointer to an integer to be updated with number of scan configurations in ppFastConfig.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

If uTransferMode is LTWAIN_NATIVE_MODE, this function will use the value of nBitsPerPixel to determine which scan configurations to get.

If uTransferMode is LTWAIN_BUFFER_MODE, this function will use both nBitsPerPixel and nBufferIteration to determine which scan configurations to get.

If uTransferMode is LTWAIN_FILE_MODE, this function will use the value of nBitsPerPixel to determine which scan configurations to get.

This function allocates storage for the array of scan configurations in ppFastConfig. When this storage is no longer needed, you must free the storage by calling L_TwainFreeScanConfig.

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: | L_TwainAcquire, L_TwainAcquireList, L_TwainInitSession, L_TwainEndSession, L_TwainOpenTemplateFile, L_TwainCloseTemplateFile, L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetNumofCapsInFile, L_TwainGetCapabilityFromFile, L_TwainAcquireMulti, L_TwainFindFastConfig, L_TwainFreeScanConfig
Topics: | Fast TWAIN (Scan Configurations)
 | TWAIN Functionality: Fast TWAIN (Scan Configuration) Functions.

Example

For complete sample, refer to TWNCONFIG demo.

For an example, refer to L_TwainFindFastConfig.


L_TwainGetSources

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetSources (hSession, pfnCallBack, uFlags, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
LTWAINSOURCEINFOCALLBACK pfnCallBack; | /* optional callback function */
L_UINT uStructSize; | /* size in bytes, of the structure passed to the callback function */
L_UINT uFlags; | /* optional flags */
L_VOID * pUserData; | /* pointer to more parameters for the callback */

Gets the available information for the TWAIN sources installed on the system.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pfnCallBack | Callback function for processing each enumerated TWAIN source. Use the function pointer as the value of this parameter.
 | L_TwainGetSources calls this callback function as it gets each TWAIN source. The callback function must adhere to the function prototype described in LTWAINSOURCEINFOCALLBACK Function.
uStructSize | Size in bytes, of the structure passed to the LTWAINSOURCEINFOCALLBACK callback function, for versioning. Use sizeof(LTWAINSOURCEINFO).
uFlags | Flags that indicate what sources to get. Possible values are:
 | Value | Meaning
 | LTWAIN_SOURCE_ENUMERATE_ALL | [0x0000] Enumerates all the available sources.
 | LTWAIN_SOURCE_ENUMERATE_DEFAULT | [0x0001] Gets only the default source (currently selected).
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

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

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: | L_TwainSelectSource.
Topics: | Managing the TWAIN Source
 | TWAIN Functionality: Property Functions.

Example

L_INT EXT_CALLBACK TwnSourcesCB(HTWAINSESSION hSession, pLTWAINSOURCEINFO pSource, L_VOID * pUserData)
{
L_TCHAR szBuffer[MAX_PATH];

memset(szBuffer, 0, sizeof(szBuffer));
wsprintf(szBuffer, TEXT("Source Name = %s\nProduct Family = %s\nManufacturer = %s\n"),
pSource->pszTwnSourceName,
pSource->pszTwnProductFamily,
pSource->pszTwnManufacturer);

MessageBox(NULL, szBuffer, TEXT("Source Info."), MB_OK);
return TWAIN_SUCCESS;
}

L_VOID TwainGetAvailableSources (HTWAINSESSION hSession)
{
L_INT nRet;

nRet = L_TwainGetSources(hSession, TwnSourcesCB, sizeof(LTWAINSOURCEINFO), LTWAIN_SOURCE_ENUMERATE_ALL, NULL);
if (nRet != SUCCESS)
MessageBox (NULL, TEXT("Error During Enumeration Procedure"), TEXT("ERROR"), MB_OK);
}


L_TwainGetSupportedTransferMode

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetSupportedTransferMode (hSession, pTransferModes)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_UINT * pTransferModes; | /* pointer to a variable */

Gets all transfer modes supported by the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pTransferModes | Pointer to a variable to be updated with a value that represents the supported transfer modes. Values may be combined using a bitwise OR ( | ). Possible values are:
 | Value | Meaning
 | TWAIN_TRANSFER_FILE | [0x001] Specifies the file transfer mode.
 | TWAIN_TRANSFER_MEMORY | [0x002] Specifies the memory transfer mode.
 | TWAIN_TRANSFER_NATIVE | [0x004] Specifies the native transfer mode.

Returns

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

Comments

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainSetTransferOptions.


L_TwainGetTransferOptions

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainGetTransferOptions(hSession, pTransferOpts, uStructSize)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTRANSFEROPTIONS pTransferOpts; | /* pointer to a structure */
L_UINT uStructSize; | /* size of the TRANSFEROPTIONS structure */

Gets current transfer options for the selected Twain source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pTransferOpts | Pointer to the TRANSFEROPTIONS structure to be updated with the current transfer options.
uStructSize | Size in bytes, of the structure pointed to by pTransferOpts, for versioning. Use sizeof(TRANSFEROPTIONS).

Returns

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

Comments

To set transfer options for the selected Twain driver, call the L_TwainSetTransferOptions function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainSetTransferOptions.


L_TwainInitSession

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainInitSession (phSession, pAppData)

pHTWAINSESSION phSession; | /* pointer to a TWAIN session handle */
pAPPLICATIONDATA pAppData; | /* pointer to a structure */

Initializes the TWAIN session.

Parameter | Description
phSession | Pointer to a TWAIN session handle. This handle is needed to acquire pages from the TWAIN source, and work with template files, containers, capabilities, and properties.
pAppData | Pointer to an APPLICATIONDATA structure. This structure will have the handle of the parent window in addition to other data about the application.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

L_TwainInitSession must be called before calling any other LEADTOOLS TWAIN toolkit functions.

When the handle to the TWAIN session is no longer needed, it should be freed by calling L_TwainEndSession. For every call to L_TwainInitSession there must be a call to L_TwainEndSession.

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: | L_TwainEndSession.
Topics: | Initializing a TWAIN Session
 | TWAIN Functionality: Session Functions.

Example

For an example, refer to L_IsTwainAvailable.


L_TwainLockContainer

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainLockContainer(pCapability, ppContainer)

TW_CAPABILITY * pCapability; | /* pointer to a structure */
L_VOID ** ppContainer; | /* pointer to a pointer to a structure */

Gets the container information for the specified capability.

Parameter | Description
pCapability | Pointer to a TW_CAPABILITY structure from which to get the container.
ppContainer | Pointer to be updated with a pointer to the container.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

This function is used to lock the container present in the TW_CAPABILITY structure.

Once the user has the pointer to the container, the container may be changed. When the user has finished changing the container he or she must call L_TwainUnlockContainer to unlock the container. Note that this can also be accomplished using the API GlobalLock and GlobalUnlock functions.

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: | L_TwainUnlockContainer.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

TW_CAPABILITY twCap;
TW_ONEVALUE * ptwOneVal = NULL;

if (twCap.ConType == TWON_ONEVALUE)
{
L_TwainLockContainer (&twCap, (void **)&ptwOneVal);
if (ptwOneVal)
{
// Do processing
L_TwainUnlockContainer (&twCap);
}
}


L_TwainOpenTemplateFile

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainOpenTemplateFile (hSession, phFile, lpszTemplateFile, uAccess)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
HTWAINTEMPLATEFILE * phFile; | /* handle to an existing template file */
L_TCHAR * lpszTemplateFile; | /* pointer to a character string */
L_UINT uAccess; | /* optional flag */

Opens the specified template file for loading or saving data.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
phFile | Pointer to a HTWAINTEMPLATEFILE file handle.
lpszTemplateFile | Character string that contains the name of the template file to open. A LEADTOOLS template files extension is .ltt.
uAccess | Flag that indicates the access type for opening the file. Possible values are:
 | Value | Meaning
 | LTWAIN_TEMPLATE_OPEN_READ | [0] Open the template file for reading. This should be used to load data from an existing template file.
 | LTWAIN_TEMPLATE_OPEN_WRITE | [1] Open the template file for writing. This should be used to save data to a template file.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Slight rewording.

A template file can be opened for either reading or writing, but not both.

For more information on template files, refer to Handling Template Files.

When a file is opened for writing, a new file is created.

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: | L_TwainTemplateDlg, L_TwainAddCapabilityToFile, L_TwainGetCapabilityFromFile, L_TwainGetNumOfCapsInFile, L_TwainCloseTemplateFile, L_TwainInitSession, L_TwainEndSession
Topics: | Handling Template Files
 | TWAIN Functionality: Template File Functions.

Example

For an example, refer to L_TwainAddCapabilityToFile.


L_TwainQueryFileSystem

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainQueryFileSystem(hSession, FileMsg, pTwFile)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
FILESYSTEMMSG FileMsg; | /* file system message */
pTW_FILESYSTEM pTwFile; | /* pointer to a structure */

Performs certain tasks, or retrieves certain information, depending on the value of the FileMsg parameter.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
FileMsg | Files system messages that determine the behavior of the function. For possible values, refer to the FILESYSTEMMSG.
pTwFile | Pointer to a TW_FILESYSTEM structure. This structure will be updated with, or will contain information used to change, the current TWAIN file system settings. This structure must be allocated.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

This function is only valid for TWAIN file systems for digital camers.

This function must be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

If the FileMsg parameter contains one of the following flags:

FILESYSTEM_MSG_CHANGEDIRECTORY

FILESYSTEM_MSG_CREATEDIRECTORY

FILESYSTEM_MSG_DELETE

FILESYSTEM_MSG_FORMATMEDIA

FILESYSTEM_MSG_RENAME

FILESYSTEM_MSG_COPY

the pTwFile parameter must contain the proper information before calling this function. This function will use the provided information to changes settings within the TWAIN files system.

If the FileMsg parameter contains one of the following flags:

FILESYSTEM_MSG_GETCLOSE

FILESYSTEM_MSG_GETFIRSTFILE

FILESYSTEM_MSG_GETINFO

FILESYSTEM_MSG_GETNEXTFILE

this function, will update the pTwFile parameter with the corresponding information.

If the FileMsg parameter contains the following flag:

FILESYSTEM_MSG_AUTOMATICCAPTUREDIRECTORY

this function will use information stored within the pTwFile parameter and will update the pTwFile parameter with any appropriate information.

For more information on the TW_FILESYSTEM structure, please refer to the TWAIN 1.9 Specification, available at www.twain.org.

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: | L_TwainInitSession, L_TwainEndSession, L_TwainStartCapsNeg, L_TwainEndCapsNeg
Topics: | Getting or Setting TWAIN File System Information
 | TWAIN Functionality: Twain File System Functions

Example

int TestTwainFileSystem(HWND hWnd)
{
HTWAINSESSION hSession;
APPLICATIONDATA AppData;
TW_FILESYSTEM twFileSys;

AppData.hWnd = hWnd;
lstrcpy (AppData.szManufacturerName, TEXT("LEAD Technologies, Inc."));
lstrcpy (AppData.szAppProductFamily, TEXT("LEAD Sample"));
lstrcpy (AppData.szVersionInfo, TEXT("Version 1.0"));
lstrcpy (AppData.szAppName, TEXT("LEAD Sample"));
AppData.uStructSize = sizeof(APPLICATIONDATA);

L_INT nRet = L_TwainInitSession(&hSession, &AppData);
if (nRet != TWAIN_SUCCESS)
MessageBox(hWnd, TEXT("Error occurred during L_TwainInitSession"), TEXT("Notice"), MB_OK);

L_TwainStartCapsNeg(hSession);

memset(&twFileSys, 0, sizeof(TW_FILESYSTEM));
nRet = L_TwainQueryFileSystem(hSession, FILESYSTEMMSG_AUTOMATICCAPTUREDIRECTORY, &twFileSys);
if (nRet != TWAIN_SUCCESS)
MessageBox(hWnd, TEXT("Error occurred during L_TwainQueryFileSystem"), TEXT("Notice"), MB_OK);

L_TwainEndCapsNeg(hSession);
L_TwainEndSession(&hSession);
return nRet;
}


L_TwainQueryProperty

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainQueryProperty (hSession, uCapability, ppltProperty)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_UINT uCapability; | /* capability constant */
pLTWAINPROPERTYQUERY * ppltProperty; | /* pointer to a pointer to a structure */
L_UINT uStructSize; | /* size, in bytes, of the structure pointed to by ppltProperty */

Gets the available property values.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
uCapability | This is a capability constant defined by the TWAIN 1.9 specification. For example if the user wants the value(s) for the transfer count, the uCapability will be ICAP_XFERCOUNT.
ppltProperty | Pointer to a pointer to a LTWAINPROPERTYQUERY structure to be updated with the property values.
 | The structure will be internally allocated if the function is successful.
 | The structure should be freed by calling L_TwainFreePropQueryStructure function.
uStructSize | Size, in bytes, of the structure pointed to by ppltProperty, for versioning. Use sizeof(TWAINPROPERTYQUERY).

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Getting these values can help in determining what values a certain TWAIN source supports for a certain capability or property.

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: | L_TwainStartCapsNeg, L_TwainEndCapsNeg, L_TwainGetProperties, L_TwainSetCapability, L_TwainGetCapability, L_TwainInitSession, L_TwainEndSession.
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Property Functions.

Example

L_INT CheckCapability (L_INT16 uValue)
{
L_INT nRet, nIndex;
pLTWAINPROPERTYQUERY pltQuery = NULL;

// Query capability possible values
nRet = L_TwainQueryProperty (g_hSession, ICAP_XRESOLUTION, &pltQuery, sizeof(LTWAINPROPERTYQUERY));
if (nRet != SUCCESS)
return nRet;

// Check for the available values of the file transfer property
switch (pltQuery->uType)
{
case TWON_ONEVALUE:
if (pltQuery->pltwOneValue->ItemType == TWTY_FIX32)
{
pTW_FIX32 ptwFixVal = (pTW_FIX32)pltQuery->pltwOneValue->Item;
if (ptwFixVal->Whole == uValue)
{
L_TwainFreePropQueryStructure(&pltQuery);
return SUCCESS;
}
}
break;
case TWON_ENUMERATION:
if (pltQuery->pltwEnumeration->ItemType == TWTY_FIX32)
{
pTW_FIX32 ptwFixVal;
for (nIndex = 0; nIndex < (L_INT)pltQuery->pltwEnumeration->NumItems; nIndex ++)
{
ptwFixVal = (pTW_FIX32)(pltQuery->pltwEnumeration->ItemList)[nIndex];
if (ptwFixVal->Whole == uValue)
{
L_TwainFreePropQueryStructure (&pltQuery);
return SUCCESS;
}
}
}
break;
}

L_TwainFreePropQueryStructure (&pltQuery);
return FAILURE;
}


L_TwainSelectSource

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSelectSource (hSession, pltSource)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pLTWAINSOURCE pltSource; | /* pointer to a structure */

Displays the TWAIN dialog box to be used to select a TWAIN source for acquiring images.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pltSource | Pointer to a structure that contains the name of the TWAIN source to select.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

Pass NULL for the pltSource parameter to display the default Twain Select Source dialog provided by the Twain Working Group. This allows the user to select the Twain device from the default Twain Select Source dialog. To select a device programmatically, set LTWAINSOURCE.pszTwainSourceName equal to the name of the desired device and then pass the address of the LTWAINSOURCE structure for the pltSource parameter.

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: | L_TwainGetSources, L_TwainInitSession, L_TwainEndSession.
Topics: | Managing the TWAIN Source
 | TWAIN Functionality: Property Functions.

Example

For an example, refer to L_TwainAcquire.


L_TwainSetAcquirePageOptions

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetAcquirePageOptions(hSession, nPaperSize, nPaperDirection)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_INT nPaperSize; | /* paper size */
L_INT nPaperDirection; | /* page orientation */

Sets the page size and orientation to be used when transferring data from the current TWAIN source.

Parameter | Description
HSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
nPaperSize | The page size to set. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).
nPaperDirection | The page orientation to set. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

Returns

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

Comments

This function internally sets the page size capability ICAP_SUPPORTEDSIZES, and the page orientation capability ICAP_ORIENTATION. For more information on these capabilities, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To get the current values of these capabilities, call the L_TwainGetAcquirePageOptions function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainGetImageEffects.


L_TwainSetCapability

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetCapability (hSession, pCapability, uFlags)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_CAPABILITY pCapability; | /* pointer to a structure */
L_UINT uFlags; | /* optional flags */

Sets the value of the specified capability.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pCapability | Pointer to the TW_CAPABILITY structure that references the capability value to set. This structure must be allocated and filled with data corresponding to the required capability before passing it to the function.
uFlags | Flags that indicate whether to set or reset the capability value. Possible values are:
 | Value | Meaning
 | LTWAIN_CAPABILITY_SET | [1] Set the capability to the value specified in pCapability.
 | LTWAIN_CAPABILITY_RESET | [2] Reset the value of the capability to the default value defined by the TWAIN source. In this case the pCapability can be NULL since it is not needed.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

To enable duplex scanning, set the CAP_DUPLEXENABLED option in the TW_CAPABILITY structure passed to this function.

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: | L_TwainStartCapsNeg, L_TwainEndCapsNeg, L_TwainSetProperties, L_TwainGetProperties, L_TwainGetCapability, L_TwainInitSession, L_TwainEndSession.
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions.

Example

For an example, refer to L_TwainAcquire.


L_TwainSetImageBitsPerPixel

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetImageBitsPerPixel(hSession, nBitsPerPixel)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_INT nBitsPerPixel; | /* bits per pixel */

Sets the bits per pixel to be used when transferring images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
nBitsPerPixel | Number of bits per pixel to set. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

Returns

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

Comments

This function internally sets the bits per pixel capability ICAP_BITDEPTH. For more information on this capability, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To obtain the current bits per pixel value, call the L_TwainGetImageBitsPerPixel function

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainSetImageUnit.


L_TwainSetImageEffects

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetImageEffects(hSession, ulFlags, pBrightness, pContrast, pHighlight)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_UINT32 ulFlags; | /* optional flags */
pTW_FIX32 pBrightness; | /* pointer to a variable */
pTW_FIX32 pContrast; | /* pointer to a variable */
pTW_FIX32 pHighlight; | /* pointer to a variable */

Sets the brightness, highlight and contrast values to be used when transferring images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
ulFlags | Flags that indicate which value(s) to set. You can combine values when appropriate by using a bitwise OR ( | ). Possible values are:
 | Value | Meaning
 | TWAIN_NEGOTIATE_BRIGHTNESS | [0x0010] Sets the brightness of the image.
 | TWAIN_NEGOTIATE_CONTRAST | [0x0020] Sets the contrast of the image.
 | TWAIN_NEGOTIATE_HIGHLIGHT | [0x0040] Sets the highlight of the image.
pBrightness | Pointer to a variable that contains the brightness value to set. Possible values range from –1000 to 1000.
pContrast | Pointer to a variable that contains the contrast value to set. Possible values range from –1000 to 1000.
pHighlight | Pointer to a variable that contains the highlight value to set. Possible values range from 0 to 255.

Returns

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

Comments

This function internally sets the brightness capability ICAP_BRIGHTNESS, the highlight capability ICAP_HIGHLIGHT, and the contrast capability ICAP_CONTRAST. For more information on these capabilities, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To get the current brightness, highlight, and contrast capability values, call the L_TwainGetImageEffects function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

void TestEffects(HTWAINSESSION hSession)
{
L_INT nRet = SUCCESS;

L_TwainStartCapsNeg (hSession);

TW_FIX32 Brightness;
nRet = L_TwainGetImageEffects (hSession, TWAIN_NEGOTIATE_BRIGHTNESS, &Brightness, NULL, NULL);
if (nRet == SUCCESS)
{
if (Brightness.Whole != 100)
{
Brightness.Whole = 100;
L_TwainSetImageEffects(hSession, TWAIN_NEGOTIATE_BRIGHTNESS, &Brightness, NULL, NULL);
}
}

L_INT nPaperSize, nPaperDirection;
nRet = L_TwainGetAcquirePageOptions (hSession, &nPaperSize, &nPaperDirection);
if (nRet == SUCCESS)
{
if (nPaperDirection != TWOR_LANDSCAPE)
L_TwainSetAcquirePageOptions (hSession, TWSS_A4, TWOR_LANDSCAPE);
}

L_TwainEndCapsNeg (hSession);
}


L_TwainSetImageFrame

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetImageFrame(hSession, pFrame)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_FRAME pFrame; | /* pointer to a structure */

Sets the image frame used when transferring images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pFrame | Pointer to a variable that contains the image frame value to set.

Returns

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

Comments

The image frame specifies the size and location of the image to acquire. To obtain the current image frame value, call the L_TwainGetImageFrame function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

TW_FIX32 FloatToTWFix32 (float Floater)
{
TW_FIX32 Fix32;
TW_INT32 Int32 = (TW_INT32)(Floater * 65536.0 + 0.5);
Fix32.Whole = (TW_INT16) (Int32 >> 16);
Fix32.Frac = (TW_UINT16) (Int32 & 0x0000FFFFL);

return Fix32;
}

void TestImageFrameOptions(HTWAINSESSION hSession)
{
L_INT nRet = SUCCESS;

L_TwainStartCapsNeg (hSession);
TW_FRAME frame;
nRet = L_TwainGetImageFrame (hSession, &frame);
if (nRet == SUCCESS)
{
frame.Left = FloatToTWFix32(0);
frame.Top = FloatToTWFix32(0);
frame.Right = FloatToTWFix32(8.5);
frame.Bottom = FloatToTWFix32(11);

L_TwainSetImageFrame(hSession, &frame);
}

L_TwainEndCapsNeg (hSession);
}


L_TwainSetImageUnit

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetImageUnit(hSession, nUnit)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_INT nUnit; | /* image unit */

Sets the image unit value used to transfer images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
nUnit | Specifies the unit value to set. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

Returns

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

Comments

This function internally sets the image unit capability ICAP_UNITS. For more information on this capability, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To obtain the current image unit value, call the L_TwainGetImageUnit function

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

void TestImageOptions(HTWAINSESSION hSession)
{
L_INT nRet = SUCCESS;

L_TwainStartCapsNeg (hSession);

L_INT nUnit;
nRet = L_TwainGetImageUnit (hSession, &nUnit);
if (nRet == SUCCESS)
{
if (nUnit != TWUN_INCHES)
L_TwainSetImageUnit(hSession, TWUN_INCHES);
}

L_INT nBPP;
nRet = L_TwainGetImageBitsPerPixel (hSession, &nBPP);
if (nRet == SUCCESS)
{
if (nBPP != 24)
L_TwainSetImageBitsPerPixel (hSession, 24);
}

L_TwainEndCapsNeg (hSession);
}


L_TwainSetJPEGCompression

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetJPEGCompression(hSession, pTwJpegComp, uFlag)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_JPEGCOMPRESSION pTwJpegComp; | /* pointer to a structure */
L_UINT uFlag; | /* flag */

Sets or restores JPEG compression options for the specified TWAIN session.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pTwJpegComp | Pointer to a TW_JPEGCOMPRESSION structure that references the JPEG compression options.
uFlag | Flag that indicates whether to set new or restore default JPEG compression options. Possible values are:
 | Value | Meaning
 | LTWAIN_SET_JPEG_COMPRESSION | [0x0001] Set new JPEG compression options
 | LTWAIN_RESET_JPEG_COMPRESSION | [0x0002] Restore default JPEG compression options

Returns

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

Comments

Depending upon the flag used, this function will either set JPEG compression options for the specified TWAIN session, or restore the default JPEG compression options for the specified TWAIN session. For more information about TW_JPEGCOMPRESSION, refer to the TWAIN 1.9 specification from the site "http://www.twain.org/".

This function must be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainGetJPEGCompression, L_TwainInitSession, L_TwainStartCapsNeg
Topics: | Using JPEG compression for a TWAIN source

Example

For an example, refer to L_TwainGetJPEGCompression.


L_TwainSetMaxXferCount

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetMaxXferCount(hSession, nMaxXferCount)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_INT nMaxXferCount; | /* transfer image count */

Sets the maximum number of images that can be transferred from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
nMaxXferCount | Specifies the maximum number of images to be transferred from the current TWAIN source.

Returns

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

Comments

This function internally sets the maximum transfer count capability CAP_XFERCOUNT. For more information on these capabilities, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To get the current value for the CAP_XFERCOUNT capability, call the L_TwainGetMaxXferCount function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

For an example, refer to L_TwainEnableDuplex.


L_TwainSetProperties

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetProperties (hSession, pltProperties, uFlags, pfnCallBack, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pLTWAINPROPERTIES pltProperties; | /* pointer to a structure */
L_UINT uFlags; | /* optional flags */
LTWAINSETPROPERTYCALLBACK pfnCallBack; | /* optional callback function */
L_VOID * pUserData; | /* pointer to more parameters for the callback */

Sets predefined capabilities of the TWAIN source in the form of properties.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pltProperties | Pointer to a LTWAINPROPERTIES structure that contains the values to set.
uFlags | Flags that indicate whether to set or reset the property values. Possible values are:
 | Value | Meaning
 | LTWAIN_PROPERTIES_SET | [1] Set the properties to the values specified in the LTWAINPROPERTIES structure.
 | LTWAIN_PROPERTIES_RESET | [2] Set the properties to their default values neglecting the values specified in the LTWAINPROPERTIES structure. In this case the LTWAINPROPERTIES pointer can be NULL since it is not used.
pfnCallBack | Optional callback function, called as each property is set. It lets the user know if an error occurred during the set operation and lets the user abort or retry.
 | If you do not provide a callback function, use NULL as the value of this parameter. No error reporting will occur.
 | If you do provide a callback function, use the function pointer as the value of this parameter.
 | The callback function must adhere to the function prototype described in LTWAINSETPROPERTYCALLBACK function.
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

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

The function can set the values of the properties to the values specified in the LTWAINPROPERTIES structure or it can reset the values defined in the structure to their default values defined by the TWAIN source.

This function must be called after L_TwainStartCapsNeg is called and before L_TwainEndCapsNeg is called.

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: | L_TwainStartCapsNeg, L_TwainEndCapsNeg, L_TwainGetProperties, L_TwainSetCapability, L_TwainGetCapability, L_TwainInitSession, L_TwainEndSession.
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Property Functions.

Example

For an example, refer to L_TwainGetProperties.


L_TwainSetResolution

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetResolution(hSession, pXRes, pYRes)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_FIX32 pXRes; | /* pointer to a variable */
pTW_FIX32 pYRes; | /* pointer to a variable */

Sets the horizontal and vertical resolution used to transfer images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pXRes | The horizontal resolution value to set.
pYRes | The vertical resolution value to set.

Returns

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

Comments

This function internally sets the horizontal and vertical resolution capabilities ICAP_XRESOLUTION and ICAP_YRESOLUTION. For more information on these capabilities, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To obtain the current resolution value, call the L_TwainGetResolution function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

void TestResoultion(HTWAINSESSION hSession)
{
L_INT nRet = SUCCESS;

L_TwainStartCapsNeg (hSession);

TW_FIX32 XRes, YRes;
nRet = L_TwainGetResolution (hSession, &XRes, &YRes);
if (nRet == SUCCESS)
{
if (XRes.Whole != 300)
XRes.Whole = YRes.Whole = 300;

L_TwainSetResolution(hSession, &XRes, &YRes);
}

L_TwainEndCapsNeg (hSession);
}


L_TwainSetRGBResponse

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetRGBResponse(hSession, pRgbResponse, nBitsPerPixel, uFlag)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTW_RGBRESPONSE pRgbResponse; | /* pointer to the RGB response */
L_INT nBitsPerPixel; | /* bits per pixel */
L_UINT uFlag; | /* optional flags */

Sets the RGB elements used when transferring data from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pRgbResponse | Pointer to a TW_RGBRESPONSE structure that references the RGB elements to be set for the TWAIN source. For more information about TW_RGBRESPONSE, www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).
nBitsPerPixel | Bits per pixel to be set. This is used to determine the number of RGB elements in the TW_RGBRESPONSE structure.
uFlag | Flags that indicate whether to set or reset the RGB elements for the TWAIN source. Possible values are:
 | Value | Meaning
 | TWAIN_RGB_RESPONSE_SET | [0x0001] Set the RGB elements for the current TWAIN source using the information provided.
 | TWAIN_RGB_RESPONSE_RESET | [0x0002] Reset the RGB elements for the current TWAIN source to the default values. Please note that defaults vary from TWAIN source to TWAIN source.

Returns

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

Comments

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

void TestRGBResponse(HTWAINSESSION hSession)
{
L_TwainStartCapsNeg (hSession);

pTW_RGBRESPONSE pRgbResponse = NULL;
pRgbResponse = (pTW_RGBRESPONSE)GlobalAllocPtr(GHND, sizeof(TW_RGBRESPONSE) + sizeof(TW_ELEMENT8) * 2);
if (pRgbResponse)
{
pRgbResponse->Response[0].Index = 0;
pRgbResponse->Response[0].Channel1 = 0;
pRgbResponse->Response[0].Channel2 = 0;
pRgbResponse->Response[0].Channel3 = 0;

pRgbResponse->Response[1].Index = 1;
pRgbResponse->Response[1].Channel1 = 255;
pRgbResponse->Response[1].Channel2 = 255;
pRgbResponse->Response[1].Channel3 = 255;

L_TwainSetRGBResponse(hSession, pRgbResponse, 1, TWAIN_RGB_RESPONSE_SET);
}

L_TwainEndCapsNeg (hSession);
}


L_TwainSetTransferOptions

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainSetTransferOptions(hSession, pTransferOpts)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
pTRANSFEROPTIONS pTransferOpts; | /* pointer to a structure */

Sets the options used for transferring data from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
pTransferOpts | Pointer to the TRANSFEROPTIONS structure that contains the transfer options to set.

Returns

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

Comments

To obtain the current transfer options, call L_TwainGetTransferOptions function.

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

void TestTransferOptions(HTWAINSESSION hSession)
{
L_INT nRet = SUCCESS;

L_TwainStartCapsNeg (hSession);

L_UINT TransferModes = 0;
nRet = L_TwainGetSupportedTransferMode (hSession, &TransferModes);
if (nRet == SUCCESS)
{
if ((TransferModes & TWAIN_TRANSFER_FILE) == TWAIN_TRANSFER_FILE)
MessageBox(NULL, TEXT("File transfer is supported"), TEXT("Notice!"), MB_OK);
}

TRANSFEROPTIONS TransOpts;
memset(&TransOpts, 0, sizeof(TRANSFEROPTIONS));
L_TwainGetTransferOptions (hSession, &TransOpts, sizeof(TRANSFEROPTIONS));
if (nRet == SUCCESS)
{
if (TransOpts.TransferMode != TWAIN_TRANSFER_FILE)
{
TransOpts.TransferMode = TWAIN_TRANSFER_FILE;
strcpy(TransOpts.szFileName, TEXT("c:\\test.bmp"));
TransOpts.uFileFormat = TWFF_BMP;
}

L_TwainSetTransferOptions(hSession, &TransOpts);
}

L_TwainEndCapsNeg(hSession);
}


L_TwainShowProgress

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainShowProgress(hSession, bShow)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_BOOL bShow; | /* flag */

Enables or disables the display of a progress indicator during the acquisition of images from the current TWAIN source.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
bShow | Flag that indicates whether to display a progress indicator during image acquisition from the current TWAIN source. Possible values are:
 | Value | Meaning
 | TRUE | Displays progress indicator during image acquisition.
 | FALSE | Hides the progress indicator during image acquisition

Returns

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

Comments

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

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: | L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainSetImageUnit, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions

Example

void TestProgress(HTWAINSESSION hSession)
{
L_TwainStartCapsNeg (hSession);

L_TwainShowProgress(hSession, TRUE);
L_TwainEndCapsNeg (hSession);
}


L_TwainStartCapsNeg

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainStartCapsNeg (hSession)

HTWAINSESSION hSession;

/* handle to an existing TWAIN session */

Starts the process of getting and setting TWAIN capabilities.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

This function must be called before calling the following functions:

L_TwainSetProperties

L_TwainGetProperties

L_TwainEnumCapabilities

L_TwainSetCapability

L_TwainGetCapability

L_TwainGetJPEGCompression

L_TwainSetJPEGCompression

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: | L_TwainEndCapsNeg, L_TwainSetProperties, L_TwainGetProperties, L_TwainSetCapability, L_TwainGetCapability, L_TwainInitSession, L_TwainEndSession.
Topics: | Getting and Setting Capabilities
 | TWAIN Functionality: Capability Functions.

Example

For an example, refer to L_TwainAcquire.


L_TwainTemplateDlg

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainTemplateDlg (hSession, lpszTemplateFile, pfnCallBack, pfnErCallBack, pUserData)

HTWAINSESSION hSession; | /* handle to an existing TWAIN session */
L_TCHAR * lpszTemplateFile; | /* pointer to a character string */
LTWAINSAVECAPCALLBACK pfnCallBack; | /* optional callback function */
LTWAINSAVEERRORCALLBACK pfnErCallBack; | /* callback function */
L_VOID * pUserData; | /* pointer to more parameters for the callback */

Displays the TWAIN source manufacturer's template dialog, without actually acquiring an image.

Parameter | Description
hSession | Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.
lpsztemplateFile | A character string that contains the name of the template file used in the saving the capability values.
pfnCallBack | Optional callback function, used to access the capability information before saving.
 | If you do not provide a callback function, use NULL as the value of this parameter.
 | If you do provide a callback function, use the function pointer as the value of this parameter.
 | The callback function must adhere to the function prototype described in LTWAINSAVECAPCALLBACK function.
pfnErCallBack | Optional callback function, called as each property is set. It lets the user know if an error occurred.
 | If you do not provide a callback function, use NULL as the value of this parameter. No error reporting will occur.
 | If you do provide a callback function, use the function pointer as the value of this parameter.
 | The callback function must adhere to the function prototype described in LTWAINSAVEERRORCALLBACK function.
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

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

This function saves the current values of all the supported capabilities to the specified file.

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: | L_TwainOpenTemplateFile, L_TwainAddCapabilityToFile, L_TwainGetCapabilityFromFile, L_TwainGetNumOfCapsInFile, L_TwainCloseTemplateFile, L_TwainInitSession, L_TwainEndSession.
Topics: | Handling Template Files
 | TWAIN Functionality: Template File Functions.

Example

L_INT EXT_CALLBACK BeforeSave (HTWAINSESSION hSession, pTW_CAPABILITY ptwCap, L_VOID * pData)
{
// Do pre operations on data to save
return SUCCESS;
}

L_INT EXT_CALLBACK SaveError (HTWAINSESSION hSession, pTW_CAPABILITY ptwCap, L_UINT uError, L_VOID * pData)
{
// Do the error handling
return SUCCESS;
}

void TestTemplateDlg(L_TCHAR L_FAR * pszFileName)
{
L_INT nRet = L_TwainTemplateDlg (g_hSession, pszFileName, BeforeSave, SaveError, NULL);
if (nRet != SUCCESS)
{
// Error check procedure
}
}


L_TwainUnlockContainer

#include "lttw2.h"

L_INT EXT_FUNCTION L_TwainUnlockContainer (pCapability)

TW_CAPABILITY * pCapability;

/* pointer to a structure */

Sets the container information of the specified capability.

Parameter | Description
pCapability | Pointer to a TW_CAPABILITY structure that contains the information to set.

Returns

SUCCESS | The function was successful.
! = SUCCESS | An error occurred. Refer to Return Codes.

Comments

This function is used to unlock the container present in the TW_CAPABILITY stucture.

To access the container so that it may be modified, call L_TwainLockContainer. This function provides the user with a pointer to the container. At this point the container may be changed. When the user has finished changing the container he or she must call L_TwainUnlockContainer to unlock the container. Note that this can also be accomplished using the API GlobalLock and GlobalUnlock functions.

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: | L_TwainLockContainer.
Topics: | How to Work with the Containers
 | TWAIN Functionality: Container Functions.

Example

For an example, refer to L_TwainLockContainer.


Raster Pro/Document/Medical Features

Raster Pro:

LEADTOOLS Raster Imaging Pro provides some imaging capabilities that are not available in the LEADTOOLS Raster Imaging product. In order to access these features, you must unlock them by calling L_UnlockSupport(L_SUPPORT_LTPRO, L_KEY_LTPRO). L_KEY_LTPRO can be found in ltkey.h.

If you are a licensed user of LEADTOOLS Raster Imaging, and would like to access Raster Imaging Pro features, you must contact Tech Support for information on obtaining a license and the unlock key for calling L_UnlockSupport.

Document/Medical:

LEADTOOLS Document Imaging, LEADTOOLS Document Imaging Suite, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite are the most comprehensive imaging toolkits on the market. No other toolkit provides as many imaging features for color, gray-scale and black & white images in one development package, and for one price. These toolkits comprise LEAD's best code and are designed for the programmer who is looking for the fastest performance, and/or the most extensive color, document, and medical imaging capabilities available.

These toolkits contain powerful annotation capabilities and optimized document image processing filters, and high performance compression, decompression and viewing of JPEG, LEAD CMP, MRC and CCITT G3/G4. The annotation capabilities enable the programmer to add text, highlights, sticky notes, audio, ellipses, buttons, lines, arrows, rectangles, polygons, redaction (blackout), hotspots, freehand scribble, pointers, bitmap and text stamps, to black & white and color images. Programmers working with document imaging will also find special processing filters such as despeckle, deskew, favor black, and scale to gray to enhance their black and white 1 bit images. Additionally, you can achieve faster rotation in 90-degree increments by applying a rotated view perspective to the bitmap. These LEADTOOLS toolkits offer the fastest software-only JPEG decoder available.

LEADTOOLS Document Imaging

The LEADTOOLS Document Imaging toolkit contains all the features available in the LEADTOOLS Raster Imaging Pro. In addition, it contains the following capabilities:

Special functions for Document (bitonal) images. The LEADTOOLS functions for bitonal images are especially useful for working with images from black-and-white scanners or FAX machines. These functions let you do things such as automatically straighten (deskew) an image, remove spots (despeckle), or clarify a scaled display (using scale-to-gray and favor-black features).

Annotation. LEADTOOLS supports annotation of images by letting you overlay images with text, lines, shapes, arrows, buttons, highlights, hot spots, sticky notes, stamps, buttons, and sounds.

Fast rotation. LEADTOOLS achieves fast rotation in 90-degree increments by applying a rotated view perspective to the bitmap.

ISIS support. LEADTOOLS supports ISIS interfaces for driving scanning devices.

Faster compression and decompression. The Document/Medical editions work faster when loading and saving LEAD CMP, JPEG, and CCITT Group 3 and Group 4 images. The LEADTOOLS functions for loading and saving are the same in all products. The only difference is in performance.

1-bit Image Clean-up. The Document toolkits include support for removing dots, blobs, holes, inverted text, lines, borders, bumps and nicks from 1-bit images.

Region Clean-up. [Document/Medical] Remove all the holes from a region.

Embedded Messages. The Document toolkits include support for embedding messages in lossless image formats like bmp, tiff, lossless jpeg, etc. The message is embedded without any visible changes to the image, and does not appreciably increase the size of the image. The message is password-protected.

Image Conversion. The Document toolkits include support for transforming a bitmap into a binary image using specified thresholds or a threshold calculated automatically based on statistical features of the bitmap.

12 and 16 bit grayscale images. [Document/Medical] Load, process, display, window level and save 12 and 16 bit grayscale images (including support for 16-bit grayscale TIFF).

48 and 64 bit color images. [Document/Medical] Load, process, display, and save 48 and 64 bit color images.

MRC Support. [Document/Medical] LEADTOOLS supports the Mixed Raster Content format for color documents containing mixed image and text components. For more information, refer to the .

Halftoning. [Document/Medical] Convert 1-, 4-, 8-, 16-, 24-, or 32-bit bitmaps to a halftoned bitmap, with a specified pattern rotation. A halftoned bitmap is a 1-bit bitmap that has been dithered for black and white printing or display.

LEADTOOLS Document Imaging Suite

The LEADTOOLS Document Imaging Suite toolkit contains all the capabilities of LEADTOOLS Document Imaging, and includes the features listed below. Please note that the OCR features are included in this toolkit, however they can also be purchased as a plug-in for the LEADTOOLS Document Imaging toolkit. Also, JBIG support is provided in this toolkit, however a JBIG Module may be added on to LEADTOOLS Document Imaging, LEADTOOLS Medical Imaging or LEADTOOLS Medical Imaging Suite.

OCR features. [Document/Medical] LEAD offers OCR features that use Scansoft Textbridge technology. Support for these features is included in the LEADTOOLS Document Imaging Suite, and can be added, via plug-in to the LEADTOOLS Document Imaging, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite toolkits. The OCR features allow you to perform optical character recognition and turn images into documents. Features include preset confidence and accuracy levels for controlling how sensitive the engine is to unrecognized text, artificial intelligence for improving recognition on documents of the same type, and built-in and user-defined lexicons for limiting the type of text to recognize within a particular zone. LEADTOOLS provides the ability to verify or correct text during, and (using LEAD's unique OCR editor) after recognition. LEAD's OCR editor ties the text being edited directly to the image, providing a visual reference to the original bitmap data. The OCR engine can perform Automatic area segmentation creating multi-layered zones, recognizing areas such as tables, rules, images and text. Or, you can manually designate up to 250 such zones. The OCR features support different fonts, sizes (5 to 72 point) and styles. Fax, dot matrix and halftones can be preprocessed to improve recognition results. The OCR Engine supports major European and Scandinavian languages (Danish, Dutch, Finnish, French, German, Italian, Norwegian, Portuguese, Russian, Spanish, and Swedish) as well as English. Support for dialects such as US. English, French Canadian, Latin American Spanish, Swiss German, and Brazilian Portuguese is also provided.

Recognized text can be exported to more than 40 different formats, including MS Word, MS Excel, Dbase andWordPerfect. The LEADTOOLS OCR features contain superior OCR processing speeds, for use in form recognition and processing applications.

LEAD's JBIG filter. [Document/Medical] LEAD includes support for this filter in the LEADTOOLS Document Imaging Suite toolkit. Support for this filter can be added to LEADTOOLS Document Imaging, LEADTOOLS Medical Imaging or LEADTOOLS Medical Imaging Suite by purchasing the JBIG Module. JBIG defines a method for lossless compression encoding of a bi-level image (two-color image). This method can also be used for coding grayscale and color images. LEADTOOLS completely supports all three types of images, giving you the ability to make full use of this powerful compression technology. LEADTOOLS also supports the progressive capability of JBIG, allowing you to store and send multiple representations of images at different resolutions without any extra storage overhead.

LEADTOOLS Medical Imaging

LEADTOOLS Medical Imaging contains all the capabilities of LEADTOOLS Document Imaging. It also includes general medical imaging technologies (1-16,24,32 bit color, 1-16 bit grayscale and window leveling of 12 and 16-bit grayscale images) and support for the DICOM file format.

DICOM file support. [Medical] LEADTOOLS Medical Imaging provides COMPLETE support for the DICOM 3.0 specification, including all standard IOD classes and modalities (CR, CT, MR, NM, US, RF, SC, VL, etc.) and complete DICOM Basic Directory support.

Window leveling. [Document/Medical] Detect and set LowBit and HighBit for image data, display images with automatic LUT intensity expansion, or set LUT entries and ranges with specific values and gradients. Display images through the LUT without changing the data, or process the image data using the LUT. Linearize the number of pixels locally in a bitmap, based on the specified color space in order to bring out the detail in dark areas of an image, and smooth the edges between blocks.

Medical Imaging Processing. [Medical] LEADTOOLS Medical Imaging provides image processing functionality designed specifically to allow you to examine and improve the quality of medical images.

LEADTOOLS Medical Imaging Suite

LEADTOOLS Medical Imaging Suite contains all the capabilities of LEADTOOLS Medical Imaging. In addition, it supports the following:

DICOM Communication support. [Medical Suite] LEADTOOLS provides COMPLETE support for DICOM Communications, including all Service Classes (Verification, Storage, Query/Retrieve, Patient Management, etc), and contains high-level communications functions simplifying the creation of DICOM client/server applications.

(Document/Medical) is used in the documentation to designate the features that are available in LEADTOOLS Document Imaging, LEADTOOLS Document Imaging Suite, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite. Those features that are available only in the Medical toolkits are indicated in the documentation by (Medical). Features available only in the LEADTOOLS Medical Imaging Suite toolkit are indicated in the documentation by (Medical Suite).

(Internet only) is used in the documentation to designate the features that are available only in the LEADTOOLS Internet toolkit.

For more information, refer to Document/Medical Edition Support and Licensing Requirements .


LEADTOOLS Reference Manuals

LEADTOOLS provides reference manuals that contain the same information as the online help. You can print them from PDF files. Please note that due to the large size of the PDF files that contain the LEADTOOLS manuals, these files are no longer included in the setup. Instead, these PDF files can be downloaded from our website at http://support.leadtools.com/SupportPortal/DesktopDefault.aspx?tabindex=3&tabid=27.

To print the PDF files, you must use the Adobe Acrobat Reader 3.0 or higher. You can download a copy of the Acrobat Reader from the Adobe web site (http://www.adobe.com). Note that different versions of the Acrobat Reader are available for different operating systems, but they all can read the same PDF files.


Topic Selection

LEAD Technologies, Inc.
Suite 400,
1201 Greenwood Cliff,
Charlotte, NC 28204

Sales@Leadtools.com
www.leadtools.com

(704) 332-5532
FAX: (704) 372-8161
Tech Support: (704) 372-9681

LEADTOOLS is ideal for developers involved in still frame, multimedia, document, medical, and vector imaging projects, including Internet/Intranet applications. Independent of the specific application requirement – scanning, file format support/conversion, compression, image processing, annotation, database support, multimedia, etc. – LEADTOOLS provides the most comprehensive, robust, flexible, and powerful imaging solution available.

Click this button to start the Licensing help file to review the License Agreements governing your use of the software.

Click this button to start the Products help file to review the full line of LEADTOOLS Products.

Click this button to start the Imaging help file to review the full line of LEADTOOLS Image Categories.