A few examples on how to get started with TWAINScanning.NET Bridgex86 mode.
What is Bridgex86?
Bridgex86 mode is our workaround for a problem of using TwainScanning with 32-bit scanner drivers in 64-bit applications. Previously, that wasn't possible because 64-bit applications can't work with 32-bit scanner drivers but with our Bridgex86 it is possible.
Bridgex86 has less functionality than our standard 32-bit library but supports the most important ones. Also, has a different workflow and it is more simple to use.
This example will list all installed scanners and the default scanner.
var allScannersResult = Bridgex86.GetAllDevices(); // gets all installed scanners
if (allScannersResult.Status == StatusType.OK)
{
Console.WriteLine("Found scanners:");
foreach (var scanner in allScannersResult.Value) // Value property holds all scanners
Console.WriteLine(scanner);
}
else
{
Console.WriteLine("No scanners found!");
}
var defaultScannerResult = Bridgex86.GetDefaultDevice(); // gets the default scanner
if (defaultScannerResult.Status == StatusType.OK)
{
Console.WriteLine("Default scanner is: " + defaultScannerResult.Value); // Value property can also be a single value
}
else
{
Console.WriteLine("No default scanner found!");
}
In this sample, we will get all the supported scanner capabilities and check if support for specific capability exists.
// if scanner is omitted then the default scanner is used
var allCapsResult = Bridgex86.GetAllSupportedCapabilities(scanner); // gets all supported capabilities
Console.WriteLine("Supported capabilities:");
foreach (var cap in allCapsResult.Value) // Value property holds all supported capabilities
Console.WriteLine(cap);
var pageSupportResult = Bridgex86.GetIsSupportedCapability("PageSize", scanner); // check support for specific capability, alias can also be used
bool isSupported = pageSupportResult.Value; // check Value property to see if supported
if (isSupported)
Console.WriteLine("It's supported");
else
Console.WriteLine("It's not supported");
var pagesResult = Bridgex86.GetSupportedPageSizes(scanner); // get all supported values for capability by using dedicated method
Console.WriteLine("Supported pages:");
foreach (var page in pagesResult.Value) // Value property holds all supported page sizes
Console.WriteLine(page);
Here we will cover a few scanning situations like adjusting scan settings, setting the desired scanner, modifying output file name, checking status, and displaying related messages.
string scanner = "MyScanner";
string outputFileName = @"C:\SomeFolder\Some\name.jpeg";
var settings = new ScanSettings(); // holds all scan settings, if omitted scanner defaults are used
settings.Device = scanner; // default scanner is used if omitted
settings.TransferMechanism = TwSX.Native;
var pgCap = Bridgex86.GetSupportedPageSizes(scanner);
settings.PageSize = (TwSS)Enum.Parse(typeof(TwSS), pgCap.Value[0]); // some values require parsing
var scanResult = Bridgex86.Acquire(outputFileName, settings);
// check status and display related messages
if (scanResult.Status == StatusType.OK)
{
Console.WriteLine("Scan successful!");
}
else if (scanResult.Status == StatusType.Warning)
{
Console.WriteLine("Scan warnings:");
Console.WriteLine(scanResult.WarningMessages);
}
else if (scanResult.Status == StatusType.Error)
{
Console.WriteLine("Scan errors:");
Console.WriteLine(scanResult.ErrorMessages);
}
else
{
Console.WriteLine("Unknown issue during scan!");
}