<div dir="ltr"><div>Alexander,</div><div>Took a peek on the sane sources and managed to get it working, with your guide.</div><div><br></div><div>Some observations:</div><div>1 - I have limited it to work with 1 Frame only. Would be nice to have an API where sane manages multi-frame situations;<br></div><div>2 - Sane is very easy, the difficult part is to convert the received bytes onto an image. Would also be nice to convert the code on scanimage.c to an API call;</div><div></div><div><br></div><div>Note:</div><div>I got it working with the Ricoh driver, will try to connect with an apple device and wireshark it<br></div><div><br></div><div>Thanks.<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Em sáb., 23 de jan. de 2021 às 05:45, Alexander Pevzner <<a href="mailto:pzz@apevzner.com">pzz@apevzner.com</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 1/22/21 11:43 PM, Thiago Milczarek Sayão wrote:<br>
> Thanks for the reply.<br>
> <br>
> Another approach is to use the C api directly and map it to java using JNI.<br>
> <br>
> I'm looking at scanimage.c file, but it deals with lots of things. Is <br>
> there a high level api?<br>
<br>
I's actually simple.<br>
<br>
1. Call sane_init() to initialize the driver<br>
2. Call sane_get_devices() to obtain list of devices<br>
3. Somehow choose a device from the list<br>
4. Call sane_open() to obtain device handle<br>
5. Call sane_start() to start scanning<br>
6. Call sane_get_parameters() to obtain image parameters<br>
7. Call sane_read() to read image data, until it returns erroneous <br>
status or zero length (which means EOF)<br>
8. Call sane_close() to release device handle<br>
9. Call sane_exit() to cleanup the driver<br>
<br>
Items 2-7 can be repeated without need to initialize/cleanup driver <br>
before/after each scan.<br>
<br>
Any of these functions may return error status code.<br>
<br>
To scan everything from ADF, you need to repeat steps 5-7, until <br>
sane_start() returns SANE_STATUS_NO_DOCS. Don't consider <br>
SANE_STATUS_NO_DOCS as an error, if you've got at least one image.<br>
<br>
It will scan with default options.<br>
<br>
Once you've get it working, I can tell you how to deal with options.<br>
<br>
-- <br>
<br>
        Wishes, Alexander Pevzner (<a href="mailto:pzz@apevzner.com" target="_blank">pzz@apevzner.com</a>)<br>
</blockquote></div>