Leadtools TWAIN (Leadtools.Twain assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
Acquire Method
See Also 
Leadtools.Twain Namespace > TwainSession Class : Acquire Method



flags
Indicates whether to display the manufacturer's user interface.
flags
Indicates whether to display the manufacturer's user interface.
Acquires one or more images from a TWAIN source.

Syntax

Visual Basic (Declaration) 
Public Function Acquire( _
   ByVal flags As TwainUserInterfaceFlags _
) As DialogResult
Visual Basic (Usage)Copy Code
Dim instance As TwainSession
Dim flags As TwainUserInterfaceFlags
Dim value As DialogResult
 
value = instance.Acquire(flags)
C# 
public DialogResult Acquire( 
   TwainUserInterfaceFlags flags
)
C++/CLI 
public:
DialogResult Acquire( 
   TwainUserInterfaceFlags flags
) 

Parameters

flags
Indicates whether to display the manufacturer's user interface.

Return Value

One of the DialogResult values. If an error occurs, an exception is thrown.

Example

Visual BasicCopy Code
Dim acq_session As TwainSession
   Private Sub twain_AcquirePage(ByVal sender As Object, ByVal e As TwainAcquirePageEventArgs)
      ' get acquired image here

      ' call StopFeeder method here if you need to stop the feeder
      acq_session.StopFeeder()
   End Sub

   Public Sub AcquireExample(ByVal parent As IWin32Window)
      acq_session = New TwainSession()
      acq_session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None)

      acq_session.SelectSource(String.Empty)

      Dim props As TwainProperties = acq_session.Properties
      Dim dataProps As TwainDataTransferProperties = props.DataTransfer
      dataProps.FileName = Path.Combine(LEAD_VARS.ImagesDir, "twain.bmp")
      dataProps.MemoryBufferSize = dataProps.MemoryBufferSize * 2
      props.DataTransfer = dataProps
      acq_session.Properties = props
      Dim opts As TwainTransferOptions = acq_session.TransferOptions

      AddHandler acq_session.AcquirePage, AddressOf twain_AcquirePage

      If acq_session.Acquire(TwainUserInterfaceFlags.Show) <> DialogResult.OK Then
         MessageBox.Show("Error Acquiring From Source")
      End If

      acq_session.Shutdown()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
TwainSession acq_session;
   private void twain_AcquirePage(object sender, TwainAcquirePageEventArgs e)
   {
      // get acquired image here

      // call StopFeeder method here if you need to stop the feeder
      acq_session.StopFeeder();
   }

   public void AcquireExample(IWin32Window parent)
   {
      acq_session = new TwainSession();
      acq_session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None);

      acq_session.SelectSource(String.Empty);

      TwainProperties props = acq_session.Properties;
      TwainDataTransferProperties dataProps = props.DataTransfer;
      dataProps.FileName = Path.Combine(LEAD_VARS.ImagesDir, "twain.bmp");
      dataProps.MemoryBufferSize = dataProps.MemoryBufferSize * 2;
      props.DataTransfer = dataProps;
      acq_session.Properties = props;
      TwainTransferOptions opts = acq_session.TransferOptions;

      acq_session.AcquirePage += new EventHandler<TwainAcquirePageEventArgs>(twain_AcquirePage);

      if (acq_session.Acquire(TwainUserInterfaceFlags.Show) != DialogResult.OK)
         MessageBox.Show("Error Acquiring From Source");

      acq_session.Shutdown();
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}

Remarks

Use the Acquire method to acquire one or more images. Use the Leadtools.Twain.TwainSession.AcquireFast method to acquire one or more images and save them to one or more files.
The number of pages to acquire can be determined by getting the TWAIN source's capabilities. To change the number of pages to acquire, set the appropriate capability to the desired number.
This method will get images from the selected TWAIN source and pass them into an RasterImage object to the TwainSession.AcquirePage event through the TwainAcquirePageEventArgs class.
For each image acquired by the currently selected TWAIN source, an TwainSession.AcquirePage event is generated.
The Acquire method acquires pages in the following transfer modes:
  • Native - gets the images being scanned into the memory as a whole.
  • Memory Buffered - gets images from the source as strips of data. These strips can be merged to get the whole image.
To set the transfer mode, call TwainSession.SetCapability with the appropriate capability constant.
For more information, refer to How to Acquire from the Twain Source.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also