LEADTOOLS Support
Imaging
Imaging SDK FAQ
How do I scan pages from my scanner?
#1
Posted
:
Thursday, April 13, 2017 8:44:56 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 39
Thanks: 2 times
Was thanked: 3 time(s) in 3 post(s)
With LEADTOOLS you would use the
TwainSession class to interact with any TWAIN device.
Scanning with LEADTOOLS is as easy as doing the following:
Code:private TwainSession twnSession;
Code://new instance of twain session and subscribe to the acquire page event
twnSession = new TwainSession();
twnSession.Startup(this.Handle, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None);
twnSession.AcquirePage += new EventHandler<TwainAcquirePageEventArgs>(twnSession_AcquirePage);
In the code snippet above we subscribe to the
AcquirePage event. This event will fire for each page acquired from the TWAIN source. In this event you have access to the image data. Here you can save the scanned file to disk, display it, apply further processing etc.
Then specify a TWAIN
source:
Code:if (twnSession.SelectSource(string.Empty) != DialogResult.OK)
MessageBox.Show("Error Selecting Source");
The following code snippet shows how you can leverage our RasterCodecs to save the scanned document to disk in the AcquirePage event.
Code:private void twnSession_AcquirePage(object sender, TwainAcquirePageEventArgs e)
{
try
{
using (RasterCodecs codecs = new RasterCodecs())
{
RasterImage image = e.Image;
codecs.Save(image, @"DESTINATION FOR SCANNED IMAGE", RasterImageFormat.Tif, 0);
}
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message);
}
}
I have attached a small .NET project that uses LEADTOOLS TWAIN support and ImageViewer control to scan from available TWAIN sources and display the scanned documents in the LEADTOOLS ImageViewer. Please note this project uses LEADTOOLS version 19 and was created using Visual Studio 2017.
An updated project can be found here: https://www.leadtools.co...from-a-twain-source.htmlEdited by moderator Wednesday, December 27, 2023 2:07:34 PM(UTC)
| Reason: Updated
Roberto Rodriguez
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Imaging
Imaging SDK FAQ
How do I scan pages from my scanner?
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.