[sane-devel] SANE crashes when scanning 16-bit color with the Epson 'epkowa' driver
Camil Băncioiu
ioan.camil.bancioiu at gmail.com
Sun Aug 5 03:42:59 BST 2018
After some investigation (using SANE_DEBUG_EPKOWA="INFO"), I found this in
the stderr of scanimage:
dip-obj.c:572: [epkowa][F] failed: require (8 == buf->ctx.depth)
With this line, scanimage crashed. For context, the file and line number
referenced by this line lead to this function in backend/dip-obj.c of the
iscan package:
/*! \todo Add support for 16 bit color values (#816).
*/
void
dip_apply_color_profile (const void *self, const buffer *buf,
const double profile[9])
{
SANE_Int i;
SANE_Byte *r_buf, *g_buf, *b_buf;
double red, grn, blu;
SANE_Byte *data;
SANE_Int size;
require (dip == self && buf && profile);
require (8 == buf->ctx.depth);
if (SANE_FRAME_RGB != buf->ctx.format)
return;
data = buf->ptr;
size = buf->end - buf->ptr;
for (i = 0; i < size / 3; i++)
{
r_buf = data;
g_buf = data + 1;
b_buf = data + 2;
red =
profile[0] * (*r_buf) + profile[1] * (*g_buf) + profile[2] * (*b_buf);
grn =
profile[3] * (*r_buf) + profile[4] * (*g_buf) + profile[5] * (*b_buf);
blu =
profile[6] * (*r_buf) + profile[7] * (*g_buf) + profile[8] * (*b_buf);
*data++ = clamp (red, 0, 255);
*data++ = clamp (grn, 0, 255);
*data++ = clamp (blu, 0, 255);
}
}
I might try to modify this function so it applies the color profile on
16-bit values too, but I need to research more. Is there a simple way to
avoid it altogether?
Kind regards,
Camil
On Sun, Aug 5, 2018 at 5:12 AM, Camil Băncioiu <
ioan.camil.bancioiu at gmail.com> wrote:
> Hello,
>
> I have an Epson v370 which, due to a driver error, can only scan colors at
> 8-bit color depth in Linux (Fedora 27). When selecting 16-bit depth from
> the Xsane options and pressing "Scan", the scanner pauses as if it is
> sending data to the computer, while Xsane crashes. Note that 16-bit depth
> works with grayscale. I need 16-bit depth to work for color mode so I can
> scan film negatives, which is the sole reason I bought the scanner.
>
> This topic has also been discussed in this mailing list:
> https://alioth-lists.debian.net/pipermail/sane-devel/2008-June/022224.html
> , where someone says that the driver assumes 8-bit color RGB, therefore it
> crashes when it receives 16-bit RGB. That person managed to fix this in a
> patch, but I couldn't find that specific patch.
>
> I currently have the following packages installed:
> iscan-2.30.2-2.x86_64
> iscan-data-1.30.0-1.x86_64
>
> iscan-plugin-perfection-v370-1.0.0-2.x86_64
> sane-backends-1.0.27-17
> xsane version 0.999
>
> I would have no issue modifying the source code myself, if I would know
> where to look. I already downloaded the source code packages for iscan and
> iscan-data from Epson. At a first glance, I think I should look into the
> iscan package, in the file backend/epkowa.c. Which function is the one
> receiving RGB data from the scanner?
>
> Kind regards,
> Camil
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20180805/6b89ba30/attachment.html>
More information about the sane-devel
mailing list