ntwain/README.md

63 lines
2.4 KiB
Markdown
Raw Normal View History

2018-11-21 10:23:34 +08:00
# TWAIN dotnet library
2014-04-03 07:01:21 +08:00
2023-04-09 07:34:57 +08:00
NOTE: This is a rewrite of the original NTwain lib and is still
in early stages. Use the V3 branch for the current version.
2018-11-19 08:40:08 +08:00
2017-02-03 08:56:25 +08:00
## Info
2018-11-11 03:09:36 +08:00
2018-11-24 09:25:07 +08:00
This is a dotnet library created to make working with
[TWAIN](http://twain.org/) devices easier in dotnet.
It internally uses some parts of the
[twaincs](https://github.com/twain/twain-cs) code from
the TWAIN Working Group.
2023-04-09 07:34:57 +08:00
V4 of this lib has these features:
2014-04-03 07:01:21 +08:00
2023-04-09 07:46:54 +08:00
* Targets TWAIN version 2.5.
2023-04-09 07:34:57 +08:00
* Runs under supported framework (4.6.2+) and netcore variants (6.0+).
* Easier to use than the low-level C API with many dotnet niceties.
* Attempt at reducing heap allocations compared to previous versions.
## Compred to older versions
These are not implemented yet in this early version:
* Image memory transfer (DAT_IMAGEMEMXFER).
* Audio native transfer (probably never will).
As with previous versions, only Windows has been tested on and thus
supported really. Other changes include
* All TWAIN data types are now struct instead of class (and they come
2023-04-11 06:45:09 +08:00
from [twaincs](https://github.com/twain/twain-cs) for correctness. It may have
been easier to implement them as classes when starting out this lib, but
2023-04-09 07:34:57 +08:00
it's not really ideal anymore. The change also makes them match the twain.h
2023-04-11 06:45:09 +08:00
names and the spec pdf.
2023-04-09 07:34:57 +08:00
2023-04-11 06:45:09 +08:00
* Caps no longer have their own wrapper properties for each type, though common
helpers are provided. This makes calling custom caps possible but you will have to
consult the docs on what containers and values they should be.
2023-04-09 07:34:57 +08:00
* All lower-level TWAIN APIs are public instead of hidden away.
* `TwainAppSession` longer hosts its own internal message pump. Apps will need to hook
2023-04-09 07:46:54 +08:00
into their UI message loop on Windows (supports Winform and WPF at the moment).
2023-04-09 07:34:57 +08:00
2014-04-08 10:50:09 +08:00
2017-02-03 08:56:25 +08:00
## Using the lib
2014-11-30 11:43:07 +08:00
Before using this lib, you are required to be reasonably
2018-11-11 03:09:36 +08:00
familiar with the TWAIN spec and understand how it works in general.
2023-04-09 07:34:57 +08:00
The TWAIN spec pdf can be downloaded from [twain.org](http://twain.org/).
The main class to use is `TwainAppSession`. This is the highest abstraction level
provided by this lib. A lower-level abstraction is the triplet calls
(under `NTwain.Triplets` namespace). The lowest level is the pinvoke dsm calls
(under `NTwain.DSM` namespace).
You use `TwainAppSession` by subscribing to its events and calling methods to do TWAIN things.
2023-04-09 07:46:54 +08:00
There is a sample winform project (both 32 and 64 bit variants) on how it can be used.
2023-04-09 07:34:57 +08:00
Note that an application process should only have one active (opened)
`TwainAppSession` at any time.