[sane-devel] Calculating maxlen
Sun, 19 Sep 2004 22:32:45 +0200
>>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=1 to max_len > size of the image.
> Okay, I need to be clear here.
> 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.
> I'm currently toying with the code so I know what has to be done when it
> comes to implementing the code for real.
you can get the size of the entire image from the result of a call of
sane_get_parameters. (Make sure that you call sane_get_parameters
_after_ the call of sane_start. Earlier calls do not necessarily return
precise values.) But you don't need to read all scan data with only one
call of sane_read. An A4 size RGB scan with 300dpi has a data size of
~24 MB, and this is perhaps more than you want to keep in RAM. For a
preview, lower resolutions are often preferable. I assume that Scribus
has some way to calculate such a preview from a high resolution image.