Visual Basic (6.0 and below) Sample: Acquire and save to BMP file |
Top Previous Next |
The following Visual Basic (6.0 and below) function is all that is required to do the following:
___________________________________________________________________ Private Sub ExampleFunction( )
Dim SelectedSource As Long Dim RetVal As Long Dim ErrStatus As Long
Rem Check for Twain if DTWAIN_IsTwainAvailable Then Rem Initialize DTWAIN
Rem open a TWAIN Source SelectedSource = DTWAIN_SelectSource if SelectedSource Then
Rem Acquire to a BMP file RetVal = DTWAIN_AcquireFile(SelectedSource, "test.bmp", DTWAIN_BMP, _ DTWAIN_USENATIVE + DTWAIN_USENAME, _ DTWAIN_PT_DEFAULT, 1, 1, 1, ErrStatus) End If Rem Shut down DTWAIN End If EndSub ________________________________________________
Add the DTWAIN32.BAS interface to the Visual Basic project to define the DTWAIN functions, and that is all that's needed to compile the function correctly. Note that this is function shows complete usage of DTWAIN from start to finish. There are no other "hidden" DTWAIN calls or setup to do. Of course, your VB application would more than likely be more advanced, however this example illustrates what can be done with just a few lines of code.
To acquire to the other file types other than BMP, the parameter that specifies DTWAIN_BMP can be any of the other file types such as DTWAIN_GIF, DTWAIN_JPEG, etc.. Therefore just 5 calls can save a file to any of many file types by just changing the third parameter to DTWAIN_AcquireFile
We will boldly challenge you to try to implement TWAIN image retrieval without DTWAIN, especially if you use Visual Basic. You will realize that you will save weeks and possibly months of programming time using DTWAIN than if you tried to implement this yourself. |