--- backend/channel-usb.c +++ backend/channel-usb.c @@ -91,6 +91,7 @@ static ssize_t channel_usb_send (channel *, const void *, static ssize_t channel_usb_recv (channel *, void *, size_t, SANE_Status *); +static size_t channel_usb_max_request_size (const channel *); channel * channel_usb_ctor (channel *self, const char *dev_name, SANE_Status *status) @@ -119,7 +120,7 @@ channel_usb_ctor (channel *self, const char *dev_name, SANE_Status *status) self->send = channel_usb_send; self->recv = channel_usb_recv; - self->max_size = 128 * 1024; + self->max_request_size = channel_usb_max_request_size; return self; } @@ -265,9 +266,6 @@ channel_interpreter_ctor (channel *self, const char *dev_name, self->dtor = channel_interpreter_dtor; } } - - self->max_size = 32 * 1024; - return self; } @@ -283,3 +281,10 @@ channel_interpreter_dtor (channel *self) self->dtor = channel_dtor; return self->dtor (self); } + +static size_t +channel_usb_max_request_size (const channel *self) +{ + return (self->interpreter ? 32 : 128) * 1024; +} + --- backend/dip-obj.c +++ backend/dip-obj.c @@ -555,44 +555,70 @@ dip_change_GRB_to_RGB (const void *self, const buffer *buf) return; } -/*! \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); + require (buf->ctx.depth == 8 || buf->ctx.depth == 16); if (SANE_FRAME_RGB != buf->ctx.format) return; - data = buf->ptr; - size = buf->end - buf->ptr; + if (buf->ctx.depth == 8) + { + SANE_Byte *r_buf, *g_buf, *b_buf; + SANE_Byte *data; + + data = buf->ptr; + size = buf->end - buf->ptr; - for (i = 0; i < size / 3; i++) + 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); + } + } + else if (buf->ctx.depth == 16) { - 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); + uint16_t *r_buf, *g_buf, *b_buf; + uint16_t *data; + + data = (uint16_t *)buf->ptr; + while(data < buf->end) + { + 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, 65535); + *data++ = clamp (grn, 0, 65535); + *data++ = clamp (blu, 0, 65535); + } } }