Development Issues

Top  Previous  Next

Since DTWAIN operates as a generic Windows 32 or 64 bit Dynamic Link Library (DLL), any Windows environment that allows calls to external DLL's can use DTWAIN.  This includes Visual Basic, Delphi, FoxPro, Access, Java (using JNI), and many others.  If you are already familiar with how to use third-party DLL's within your application, you can skip this topic.

 

Note for Visual Basic programmers:  DTWAIN DLL is not an ActiveX DLL.  The following topics discuss the various programming environments and the interface to DTWAIN.

 

C and C++ Development Issues

Visual Basic Development

Borland Delphi Development

C# Development

Visual FoxPro Development

Development in Other Languages

 

Consult the user's manual of your programming environment for information on how to make calls to external DLL's.  If you need to set up an interface to the DTWAIN functions and are not sure how to set up the parameters for the DTWAIN functions, the best approach is to see how your environment defines the parameters when calling a Windows API function such as CreateWindow, BitBlt, GetWindowText, etc.  Almost all programming documentation for various languages have code samples of calling a Windows API function, so you can use this as a template when interfacing to DTWAIN.

 

Most of the DTWAIN function parameter types match as closely as possible to the usual parameter types that you will see associated with Windows API functions. For example, LPCSTR, LPVOID, LONG, BOOL, etc. that DTWAIN uses are exactly the same types as used with the Windows API functions.

 

Here is a small table of how to interpret the various DTWAIN types using the standard 'C' language types:

 

DTWAIN Type

Definition

'C' / Windows equivalent

DTWAIN_SOURCE        

32-bit integer

LONG

LPDTWAIN_SOURCE

32-bit void pointer

void FAR * (or LPVOID)

DTWAIN_ARRAY

32-bit integer

LONG

LPDTWAIN_ARRAY

32-bit void pointer

void FAR * (or LPVOID)

DTWAIN_IDENTITY

32-bit integer

LONG

DTWAIN_STRING

array of 256 chars

LPSTR

DTWAIN_LONGSTRING

array of 1,024 chars

LPSTR

DTWAIN_FLOAT

8 byte IEEE floating point

double

DTWAIN_LONG

32-bit integer

LONG

DTWAIN_BOOL

32-bit integer

LONG

DTWAIN_LONG64

64-bit integer

LONGLONG (or __int64)

 

 

For 64-bit applications, some of the above definitions will be 64-bit integers and pointers.  Here is a table of the differences between the 32-bit definitions and 64-bit definitions:

 

DTWAIN Type

Definition

'C' / Windows equivalent

DTWAIN_SOURCE        

64-bit integer

LONGLONG (or __int64)

LPDTWAIN_SOURCE

64-bit void pointer

void FAR * (or LPVOID)

DTWAIN_ARRAY

64-bit integer

LONGLONG (or __int64)

LPDTWAIN_ARRAY

64-bit void pointer

void FAR * (or LPVOID)

DTWAIN_IDENTITY

64-bit integer

LONGLONG (or __int64)

 

 

 

Bitmap Data and TWAIN

 

Unless you're calling DTWAIN functions that automatically create image files from scanned images (for example, DTWAIN_AcquireFile), by default TWAIN returns Device Independent Bitmaps (DIBs) to your application, therefore you should be familiar with how to handle this image type within your language and application.   An example of DTWAIN functions that return DIBS are DTWAIN_AcquireNative and DTWAIN_AcquireBuffered (when acquiring uncompressed image data)

 

Since DIB's are one of the most common formats in the Windows environment, you should be able to consult documentation on how to handle this format.  If you have libraries that handle Windows BMP files, the same library or code can be used to handle a DIB.  The example programs found in the /EXAMPLES/C and /EXAMPLES/C++ directory include portions of the DIBVIEW program that demonstrates handling of Device Independent Bitmaps.

 

If you are not familiar with handling DIB's, we suggest that you get one of the many ActiveX or third party libraries that can display or manipulate Device Independent Bitmaps.  Here are a few libraries with their web site address:

 

ImgSource by SmallerAnimals Inc.    

http://www.smalleranimals.com

LeadTools by Lead Technologies

http://www.lead.com

Victor Imaging Library

http://www.catenary.com