Borland Delphi Sample: Acquire and save to BMP file

Top  Previous  Next

The following Delphi example all that is required to do the following:

 

Check if TWAIN is installed.
Initialize the DTWAIN Dynamic Link Library.
Select a Source
Acquire a page using the Native transfer mode
Save page to a BMP file called "test.bmp"
Shut down any open TWAIN Source's and DTWAIN itself

___________________________________________________________

procedure TForm1.Acquire(Sender: TObject);

var

  AcquiredOk:DTWAIN_BOOL;

 

begin

  { Check for TWAIN availability }

  if (DTWAIN_IsTwainAvailable) then

  begin

     { Initialize DTWAIN }

     if (DTWAIN_SysInitialize <> 0) then

     begin

          AcquiredOk := DTWAIN_TwainSave("-f test.bmp");

     end;

    DTWAIN_SysDestroy

     end

  end

end;

___________________________________________________________

 

That's all there is to it.   To use DTWAIN with Delphi, your Delphi project must add the DTWAIN32.PAS that comes with DTWAIN to your project.