C# Imaging - Twain Scanning in C#.NET

Provide Complete C# Codes for Twain Scanning in .NET Applications

Visual C#
Home > .NET Imaging SDK > C# > Twain Scanning
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

Fast Twain scanning can be easily achieved with advanced Twain SDK Add-On developed by RasterEdge. And the following functions are supported by this mature add-on.
  • Acquire images from DIB and files
  • Acquire images to an FTP or HTTP server
  • Control the acquired image resolution in dpi, position, size, and orientation
  • Scan images with multiple color: grayscale, palette or full color
  • Support a batch of images fast scanning
  • Support duplex scanning for both front and back of pages
Twain Scanning for C#.NET Application
This guide tells users how to acquire images from scanners, capture cards and digital cameras with RasterEdge .NET Imaging SDK and Twain SDK using Visual C# sample codes. (For VB.NET developers, please go to Twain Scanning for VB.NET. Want to view Image and document in WinForms or Web applications, please go to Twain Scanning in WinForms and Web Document Image Twain Scanning.)
  1. Run Microsoft Visual Studio (2005 or above version);
  2. Create a project with Visual C# programming language;
  3. Activate .NET Imaging SDK license and copy created "RasterEdgeLicense.txt" to the new project folder, together with .NET Imaging SDK DLL(s);
  4. Add RasterEdge DocImageSDK & RasterEdge.Imaging.Twain.dll to your Visual C# application;
  5. Call RasterEdge .NET Image SDK Namespace:
using System.IO;
using RasterEdge.Imaging;
using RasterEdge.Imaging.Processing;
using RasterEdge.Imaging.Twain;
How to Acquire Image in C# Project
The following C# code shows how to acquire images when you use twain technology.
public int TwainAcquireToRasterEdgeImageImage(int HANDLE);
// Acquire a single image, from the currently selected Data Source to a DIB handle
public IntPtr TwainAcquireToDib(IntPtr HANDLE);
// Acquire a single image, from the currently selected Data Source to a file
public RasterEdgeImageStatus TwainAcquireToFile(String FilePath, int HANDLE);
How to Initialize TWAIN Session in C# Project
The following C# code shows how to initialize the TWAIN session.
public void Startup( IWin32Window owner, string manufacturer,   string productFamily, string version, string application, 
TwainStartupFlags flags);
How to Acquire Upload Image to Server in C# Project
The following C# code shows how to upload image to sever.
private void UploadImage(System.Drawing.Bitmap image)
{
RasterEdge.Twain.HttpPost post = new RasterEdge.Twain.HttpPost(); post.FormData.Add("image1", image,
"filename.png");
post.FormData.Add("username", user);
post.FormData.Add("password", password);
string ret = post.PostData("http://www.website.com/postImage.aspx");
}
How to Acquire Image Size and Position in C# Project
The following C# code shows how to control acquired image position and size.
this.device.Units = UnitType.Inches;
if (this.device.Units != UnitType.Inches) return;
this.device.Frame = new System.Drawing.RectangleF(0, 0, 8.5, 11);
More Tutorials!
Find more user guides with RasteEdge .NET Image SDK using Visual C# sample codings!
Want to install Imaging SDK in Winforms or Web applications, please go to Use Imaging SDK in Winforms and Web Document Image Viewer.


Recommend this to Google+