On 1/22/21 11:43 PM, Thiago Milczarek Sayão wrote:
Thanks for the reply.

Another approach is to use the C api directly and map it to java using JNI.

I'm looking at scanimage.c file, but it deals with lots of things. Is there a high level api?

I's actually simple.

1. Call sane_init() to initialize the driver
2. Call sane_get_devices() to obtain list of devices
3. Somehow choose a device from the list
4. Call sane_open() to obtain device handle
5. Call sane_start() to start scanning
6. Call sane_get_parameters() to obtain image parameters
7. Call sane_read() to read image data, until it returns erroneous status or zero length (which means EOF)
8. Call sane_close() to release device handle
9. Call sane_exit() to cleanup the driver

Items 2-7 can be repeated without need to initialize/cleanup driver before/after each scan.

Any of these functions may return error status code.

To scan everything from ADF, you need to repeat steps 5-7, until sane_start() returns SANE_STATUS_NO_DOCS. Don't consider SANE_STATUS_NO_DOCS as an error, if you've got at least one image.

It will scan with default options.

Once you've get it working, I can tell you how to deal with options.

--

        Wishes, Alexander Pevzner ([email protected])

Reply via email to