Saraff.TwainX
1.0.35
dotnet add package Saraff.TwainX --version 1.0.35
NuGet\Install-Package Saraff.TwainX -Version 1.0.35
<PackageReference Include="Saraff.TwainX" Version="1.0.35" />
<PackageVersion Include="Saraff.TwainX" Version="1.0.35" />
<PackageReference Include="Saraff.TwainX" />
paket add Saraff.TwainX --version 1.0.35
#r "nuget: Saraff.TwainX, 1.0.35"
#:package Saraff.TwainX@1.0.35
#addin nuget:?package=Saraff.TwainX&version=1.0.35
#tool nuget:?package=Saraff.TwainX&version=1.0.35
Saraff.TwainX (.NET Standard 2.0)
Saraff.TwainX is the skillful scanning component which allows you to control work of flatbed scanner, web and digital camera and any other TWAIN device from .NET environment. You can use this library in your programs written in any programming languages compatible with .NET technology.
Products
This repository contains two separate products. They are not interchangeable: the package id, assembly name, namespace and public API are different.
| Product | Branch | Package | Target | Main class | Image transfer |
|---|---|---|---|---|---|
| Saraff.Twain | master |
Saraff.Twain |
net462, net8.0-windows |
Saraff.Twain.Twain32 |
System.Drawing.Image / WPF ImageSource |
| Saraff.TwainX | twainx |
Saraff.TwainX |
netstandard2.0 |
Saraff.TwainX.TwainX |
Stream via IImageFactory<T> |
Saraff.TwainX (this branch)
Cross-platform implementation for TWAIN 2.x (DS2) data sources. It does not depend on WinForms or WPF, uses IntPtr for the parent window and transfers images as streams.
ShowUIdefaults tofalse.ParentisIntPtrand is applied toDG_CONTROL / DAT_USERINTERFACE / MSG_ENABLEDS.Acquire()requires a TWAIN 2.x/DS2 data source and a TWAIN 2.x DSM.DsmPathcan be used to point to a non-defaultlibtwaindsm/TWAINDSMlibrary.
Asynchronous acquisition
AcquireAsync uses a dedicated session thread. On Windows the thread is STA and pumps Win32 messages; on other platforms it is a serialized background thread without a Win32 message pump.
using var session = new TwainXAcquisitionSession(new TwainXAcquireOptions {
ShowUI = true,
DisableAfterAcquire = true,
MaxImages = 1
});
using var result = await session.AcquireAsync();
foreach (var stream in result.Streams) {
// stream is a result-owned MemoryStream copied from the transfer
}
The overload with a callback runs it on the session thread after the data source is opened and before it is enabled. This is the point where capabilities, image layout and other data source settings can be applied:
using var result = await session.AcquireAsync(twain => {
twain.Capabilities.XResolution.Set(300);
twain.Capabilities.YResolution.Set(300);
twain.Capabilities.PixelType.Set(TwPixelType.Gray);
});
The synchronous Acquire() API remains available and unchanged.
Install-Package Saraff.TwainX
Saraff.Twain
Windows implementation. Supports TWAIN 1.x and TWAIN 2.x data sources, WinForms/WPF parents, System.Drawing.Image results and the Twain32 component.
Install-Package Saraff.Twain
Documented differences
Do not assume that Twain32 and TwainX have identical defaults or signatures:
ShowUIdefaults totrueinTwain32and tofalseinTwainX.ParentisIWin32WindowinTwain32andIntPtrinTwainX.Twain32exposesGetImage,ImageCount,Image,ImageSource,IsTwain2EnableandIsTwain2Supported;TwainXdoes not.TwainXrequires a TWAIN 2.x/DS2 source and a TWAIN 2.x DSM.TwainX.EndXferEventArgs.Streamexposes the underlying stream; it is rewound to the beginning and remains owned by the event args.
Build
dotnet build Saraff.TwainX.csproj -c Release
dotnet test tests/Saraff.TwainX.Tests/Saraff.TwainX.Tests.csproj -c Release
Also, you can see:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.