Using the Fast TWAIN Feature (C++ Builder 6.0)

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

1.

Start C++ Builder 6.0.

2.

If you didn’t import LEAD Raster Twain before, import it as follows:

 

On the Project pull-down menu, use Import Type library… and select the LEAD RasterTwain Object Library (14.5). Press install, and then compile and install the package dclusr.bpk.

3.

If you didn’t import LEAD Raster IO before, import it as follows:

 

On the Project pull-down menu, use Import Type library… and select the LEAD Raster IO Object Library (14.5). Press install, and then compile and install the package dclusr.bpk.

4.

If you didn’t import LEAD Raster before, import it as follows:

 

On the Project pull-down menu, use Import Type library… and select the LEAD Raster Object Library (14.5). Press install, and then compile and install the package dclusr.bpk.

5.

From the ActiveX controls tab, add the LEAD Raster Twain and LEAD Twain Capability controls to your form.

6.

Add the following declaration to the private section of "Unit1.h":

int nRet;

7.

At the top of your form, add a check box and name it as follows:

 

Name

Caption

 

chkUseBufferSize

Use Buffer Size

8.

Add 2 radio buttons to your form, and name them as follows:

 

Name

Caption

 

RbNative

Native Mode

 

RbMemory

Memory Mode

9.

Add 1 button to your form, and name it as follows:

 

Name

Caption

 

btnAcquire

Fast Acquire

10.

Add 2 Edit boxes to your form, and name them as follows:

edtBufferSize
edtFName

11.

Handle the Form1 OnCreate event, and code the FormCreate procedure as follows:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   LEADRasterTwain1->UnlockSupport ( L_SUPPORT_DOCUMENT, AnsiToOLESTR("TestKey") ) ;
   LEADRasterTwain1->InitSession ( (long)Handle ) ;
   LEADRasterTwain1->set_EnableMethodErrors ( false );
   rbMemory->Checked= true;
}

12.

Handle the Form1 OnClose event, and code the FormClose procedure as follows:

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
   LEADRasterTwain1->EndSession ( ) ;
}

13.

Handle the btnAcquire control's OnClick event, and code the btnAcquireClick procedure as follows. In online help, you can use the Edit pull-down menu to copy the block of code.

void __fastcall TForm1::btnAcquireClick(TObject *Sender)
{
   if ( rbMemory->Checked )
   {
      LEADRasterTwain1->set_FastTransferMode ( L_LTWAIN_BUFFER_MODE );
      LEADRasterTwain1->set_FastFormat ( FILE_CCITT_GROUP4 );
   }
   else
   {
      LEADRasterTwain1->set_FastTransferMode ( L_LTWAIN_NATIVE_MODE );
      LEADRasterTwain1->set_FastFormat ( FILE_TIF );
   }

   LEADRasterTwain1->set_FastBitsPerPixel ( 1 ) ;
   LEADRasterTwain1->set_FastUsePreferredBufferSize ( chkUseBufferSize->Checked );
   if (LEADRasterTwain1->FastUsePreferredBufferSize )
      LEADRasterTwain1->set_FastBufferSize ( StrToInt(edtBufferSize->Text) );

   nRet= LEADRasterTwain1->AcquireMulti ( AnsiToOLESTR(edtFName->Text.c_str()), L_LTWAIN_SHOW_USER_INTERFACE | L_LTWAIN_USE_THREAD_MODE, true );
   if ( nRet == 0 )
      ShowMessage ( "Fast Scanning process done successfully..." );
   else
      ShowMessage ( "AcquireMulti failed, Error = " + IntToStr ( nRet ) ) ;
}

14.

Include the following files in the "Unit1.h" file.

#include "LTRASTERLib_TLB.h"
#include "LTRASTERIOLib_TLB.h" 

15.

Save your project and run your program to test it.