[sane-devel] Re: maxlen
Mon, 20 Sep 2004 16:08:11 +0200
Excuse me for my major mistake in sending the almost entire digest... I
really did mean to clip it all, but I just clicked send a second too
Here's the short version of the mail I sent... (ooops!)
Dave Neary wrote:
> Hi Paul,
> Paul said:
>>> max_len is set by the frontend. The buffer is allocated by the frontend
>>> and the size of the buffer must be at least max_len bytes.
>>> max_len and the size of the buffer are arbitary. The backend must be
>>> able to handle each size from max_len=3D1 to max_len > size of the
>> max_len is some size large enough to scan something in. How do I know
>> how big to make this to (say) scan an A4 picture at 8bpp resolution? To
>> me, it looks like I multiply bytes_per_line * pixels_per_line * lines *
>> depth to accomodate everything.
> You set max_len to whatever value suits you. Let's say you want to deal
> with the image data in 16K blocks, you would allocate a buffer for 16K
> of data, call sane_read to fill it, check for Sane_EOF as the status, do
> what you want to do with that chunk of data, and the call sane_read
> again. Basically, you are reading scanlines (the width of the scanlines
> and the bytes per pixel are in the parameters for the scan), and you
> keep calling sane_read until you get to the end of the file. At which
> stage you have a choice to call sane_start again to go onto the next
> page in an ADF, or call sane_close() to close the scanner and free it up
> for other connections.
>> I'm currently toying with the code so I know what has to be done when it
>> comes to implementing the code for real.
> There's one excellent page on the sane-project.org webpage which shows a
> typical code flow for a sane application frontend. Unfortunately, it
> seems like the site is down right now, so I don't have the URL.
110 ave Jean Jaures, 69007 Lyon