Lot of our customers asking us about a way to acquire images from scanner and other imaging devices.

There are 2 ways to acquire image in Windows:

  • via TWAIN interface (used since 1992);
  • via WIA (currently is recommended by Microsoft over TWAIN/STI because of better user experience)
To acquire images using TWAIN we have open-source SDK called Bytescout Scan SDK which is available for free download at http://bytescoutscansdk.codeplex.com/
Scan SDK is free for use in both commercial and non-commercial apps
What about WIA? In the latest version of BarCode Reader SDK we have implemented new WIAImageScanner class that allows to acquire images and works on Windows XP, Vista, 7, Windows 8 for both x86 and x64 platforms.

The latest evaluation version of BarCode Reader SDK is available for download here
Registered users should download using their “secret” link instead (to get full version)

How to use this new WIAImageScanner class:

C# code sample:
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Bytescout.BarCodeReader;

// This example demonstrates camera image acquiring using Windows Image Acquisition (WIA).
// using built-in WIAImageScanner class from barCode Reader SDK

namespace BarcodeFromWebCam
static class Program
static void Main()
// create WIA scanner object
WIAImageScanner wiaScanner = new WIAImageScanner();

wiaScanner.OutputFileNameTemplate = "BarCodeReader-scanned";
wiaScanner.OutputImageFormat = WiaImageFormatType.PNG;
wiaScanner.ImageQuality = WiaImageBias.MaximizeQuality;
wiaScanner.ImageIntent = WiaImageIntent.UnspecifiedIntent;
wiaScanner.ShowDeviceSelectionDialog = true;

// run acquire and exit if canceled or zero images
if (!wiaScanner.Acquire())

catch (Exception E)
string message = E.Message;
if (E.InnerException != null)
message = message + "rnrn" + E.InnerException.Message;
MessageBox.Show("Error while acquiring images:rnrn" + message);

// Read barcode:
Reader barcodeReader = new Reader();
FoundBarcode[] barcodes = barcodeReader.ReadFrom(wiaScanner.OutputFiles[0]);

if (barcodes.Length > 0)
StringBuilder builder = new StringBuilder();

foreach (FoundBarcode barcode in barcodes)
builder.AppendLine(String.Format("Found barcode with type '{0}' and value '{1}'", barcode.Type, barcode.Value));

MessageBox.Show(wiaScanner.OutputFiles[0] + "rnrnCould not find any barcode.");


Visual Basic .NET sample code:

Imports System.IO
Imports System.Text
Imports System.Windows.Forms
Imports Bytescout.BarCodeReader

' This example demonstrates camera image acquiring using Windows Image Acquisition (WIA).
' using built-in WIAImageScanner class from barCode Reader SDK

NotInheritable Class Program
Private Sub New()
End Sub
Friend Shared Sub Main()

' use WIA barcode reader scanner
Dim wiaScanner As WIAImageScanner = New WIAImageScanner

wiaScanner.OutputFileNameTemplate = "BarCodeReader-scanned"
wiaScanner.OutputImageFormat = WiaImageFormatType.PNG
wiaScanner.ImageQuality = WiaImageBias.MaximizeQuality
wiaScanner.ImageIntent = WiaImageIntent.UnspecifiedIntent
wiaScanner.ShowDeviceSelectionDialog = True

' run acquire and exit if canceled or zero images
If Not wiaScanner.Acquire() Then
End If

Catch E As Exception
Dim message As String = E.Message
If E.InnerException IsNot Nothing Then
message = message + "rnrn" + E.InnerException.Message
MessageBox.Show("Error while acquiring images:rnrn" + message)
End If
End Try

' Read barcode:
Dim barcodeReader As New Reader()
Dim barcodes As FoundBarcode() = barcodeReader.ReadFrom(wiaScanner.OutputFiles(0))

If barcodes.Length > 0 Then
Dim builder As New StringBuilder()

For Each barcode As FoundBarcode In barcodes
builder.AppendLine([String].Format("Found barcode with type '{0}' and value '{1}'", barcode.Type, barcode.Value))

MessageBox.Show(wiaScanner.OutputFiles(0) + "" & Chr(13) & "" & Chr(10) & "" & Chr(13) & "" & Chr(10) & "Could not find any barcode.")

End If

End Sub
End Class