Using the Fast TWAIN Feature (Visual FoxPro 6)

Take the following steps to add some code that acquires the images using Fast Twain:

1.

Start with the project you created in Acquiring an Image (Visual FoxPro 6).

2.

Add an option group with 2 radio buttons to form1 and change its name to optTransMode. Set the buttons' captions to "Native Mode" and "Memory Mode", respectively.

3.

Change the code of the form's Init procedure to be as follows:

#DEFINE L_SUPPORT_DOCUMENT 0
&& Unlock Document support.
&& Note that this is a sample key, which will not work in your toolkit.
oRasterTwain.UnlockSupport(L_SUPPORT_DOCUMENT, "DocKey")
oRasterTwain.InitSession(ThisForm.RasterView1.Window)
TheForm = ThisForm
oRasterTwain.EnableMethodErrors = .F.
ThisForm.optTransMode.Value = 2 &&Memory

4.

Add a check box to form1 and name it as follows:

 

Name

Caption

 

chkUseBufferSize

Use Buffer Size

5.

Add one button to form1 and name it as follows:

 

Name

Caption

 

FastAcquire

Fast Acquire

6.

Add two text boxes and name them as follows:

txtBufferSize

txtFName

7.

Code the Fast Acquire button Click procedure as follows:

#define L_LTWAIN_BUFFER_MODE 2
#define L_LTWAIN_NATIVE_MODE 4
#define FILE_CCITT_GROUP4 29
#define FILE_TIF 3
#define L_LTWAIN_SHOW_USER_INTERFACE 1
#define L_LTWAIN_USE_THREAD_MODE 8
If ThisForm.optTransMode.Value = 2 Then &&Memory
   oRasterTwain.FastTransferMode = L_LTWAIN_BUFFER_MODE
   oRasterTwain.FastFormat = FILE_CCITT_GROUP4
Else
   oRasterTwain.FastTransferMode = L_LTWAIN_NATIVE_MODE
   oRasterTwain.FastFormat = FILE_TIF
EndIf

oRasterTwain.FastBitsPerPixel = 1
oRasterTwain.FastUsePreferredBufferSize = ThisForm.chkUseBufferSize.Value
oRasterTwain.FastBufferSize = Val(ThisForm.txtBufferSize.Text)

nRet = oRasterTwain.AcquireMulti(ThisForm.txtFName.Text, BitOR(L_LTWAIN_SHOW_USER_INTERFACE, L_LTWAIN_USE_THREAD_MODE), .T.)
If nRet = 0 Then
   MessageBox("Fast Scanning process done successfully...")
Else
   MessageBox("The AcquireMulti method failed, Error = " + Str(nRet))
EndIf

8.

Save your project and run the PRG program to test it.