How to Start using DTWAIN
DTWAIN has so many functions, where do I start?
The first path is to start using DTWAIN is to try a very simple example using the API functions. Even though the functions are low-level, you just need a few calls to get a workable TWAIN-enabled program up and running.
Once you are comfortable with an easy example, you can progress to the other aspects of DTWAIN such as setting device capabilities, setting the contrast/brightness/resolution, define the area of acquisition, using the document feeder, and other aspects that the simple example doesn't address.
DTWAIN Detailed Information describes all of the "advanced" topics.
The following illustrates a very simple example of a function that acquires a single page to a BMP file.
Note that if your language is not one of the ones listed above, DTWAIN will still work for you if the language that you're using has the ability to call exported DLL functions. Most Microsoft Windows-based languages have the ability to do this. Please consult your programmer's manual for more information.
Note that the example is very simple in terms of function calls (acquiring a single page to a BMP file), and should be enough to get you started. However, in the simple example, there is a lot of power in those few function calls. The difference in the amount of programming code and time to implement the simple example and what you would have to write if not using DTWAIN, is enormous.
The example just scratches the surface of what DTWAIN can do. For example, if you want to acquire to a multipage TIFF file, no problem. Just use the example program and change the file type to one of the multipage TIFF types (for example DTWAIN_TIFFLZWMULTI), change the number of pages to acquire to DTWAIN_ACQUIREALL instead of 1, and that's it.
If you wanted to acquire an image so that you can use the image data for some purpose (maybe you have your own imaging library), just change the call from DTWAIN_AcquireFile to DTWAIN_AcquireNative or DTWAIN_AcquireBuffered, for example, and you can then process the raw image data in the form of a memory block of information. If you want to acquire the image to the Windows clipboard, you have DTWAIN_AcquireToClipboard (there are more acquisition functions to choose from that will surely fit your needs).
Of course you can set various aspects of the TWAIN device such as resolution, contrast, brightness, and any capability supported by the TWAIN device.
Note that in the simple sample program there is no check for error return values. This is done for brevity, however your application should check for potential error return values from the DTWAIN functions.
For more advanced examples, the DTWAIN installation contains samples of more advanced DTWAIN processing. Also see DTWAIN Advanced Topics for a thorough rundown and explanation of each of the aspects of using DTWAIN to its fullest potential.
|