kopia lustrzana https://gitlab.com/sane-project/backends
epson2: removed invert image, cleaned up some code
Image inversion is something that can be handled by a frontend, in the epson2 backend I want to avoid to add any complexity that doesn't belong to the hardware.merge-requests/1/head
rodzic
45fef7b043
commit
92f729ea83
|
@ -208,25 +208,11 @@ esci_set_gamma_table(Epson_Scanner * s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* When handling inverted images, we must also invert the user
|
|
||||||
* supplied gamma function. This is *not* just 255-gamma -
|
|
||||||
* this gives a negative image.
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (table = 0; table < 3; table++) {
|
for (table = 0; table < 3; table++) {
|
||||||
gamma[0] = gamma_cmds[table];
|
gamma[0] = gamma_cmds[table];
|
||||||
|
|
||||||
if (s->invert_image) {
|
for (n = 0; n < 256; ++n)
|
||||||
for (n = 0; n < 256; ++n) {
|
gamma[n + 1] = s->gamma_table[table][n];
|
||||||
gamma[n + 1] =
|
|
||||||
255 - s->gamma_table[table][255 - n];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (n = 0; n < 256; ++n) {
|
|
||||||
gamma[n + 1] = s->gamma_table[table][n];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
status = e2_cmd_simple(s, params, 2);
|
status = e2_cmd_simple(s, params, 2);
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
|
|
|
@ -171,14 +171,6 @@ static const int color_params[] = {
|
||||||
0x80
|
0x80
|
||||||
};
|
};
|
||||||
|
|
||||||
/* used for several boolean choices */
|
|
||||||
static int switch_params[] = {
|
|
||||||
0,
|
|
||||||
1
|
|
||||||
};
|
|
||||||
|
|
||||||
#define mirror_params switch_params
|
|
||||||
|
|
||||||
static const SANE_Range outline_emphasis_range = { -2, 2, 0 };
|
static const SANE_Range outline_emphasis_range = { -2, 2, 0 };
|
||||||
|
|
||||||
|
|
||||||
|
@ -895,16 +887,11 @@ e2_set_extended_scanning_parameters(Epson_Scanner * s)
|
||||||
|
|
||||||
/* ESC K, set data order / mirroring */
|
/* ESC K, set data order / mirroring */
|
||||||
if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_MIRROR].cap))
|
if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_MIRROR].cap))
|
||||||
buf[36] = mirror_params[s->val[OPT_MIRROR].w];
|
buf[36] = s->val[OPT_MIRROR].w;
|
||||||
|
|
||||||
s->invert_image = SANE_FALSE; /* default: do no invert the image */
|
|
||||||
|
|
||||||
/* ESC N, film type */
|
/* ESC N, film type */
|
||||||
if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_FILM_TYPE].cap)) {
|
if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_FILM_TYPE].cap))
|
||||||
s->invert_image =
|
|
||||||
(s->val[OPT_FILM_TYPE].w == FILM_TYPE_NEGATIVE);
|
|
||||||
buf[37] = film_params[s->val[OPT_FILM_TYPE].w];
|
buf[37] = film_params[s->val[OPT_FILM_TYPE].w];
|
||||||
}
|
|
||||||
|
|
||||||
/* ESC M, color correction */
|
/* ESC M, color correction */
|
||||||
buf[31] = color_params[s->val[OPT_COLOR_CORRECTION].w];
|
buf[31] = color_params[s->val[OPT_COLOR_CORRECTION].w];
|
||||||
|
@ -1027,14 +1014,10 @@ e2_set_scanning_parameters(Epson_Scanner * s)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->invert_image = SANE_FALSE; /* default: to not inverting the image */
|
|
||||||
|
|
||||||
if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_FILM_TYPE].cap)) {
|
if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_FILM_TYPE].cap)) {
|
||||||
s->invert_image =
|
|
||||||
(s->val[OPT_FILM_TYPE].w == FILM_TYPE_NEGATIVE);
|
|
||||||
status = esci_set_film_type(s,
|
status = esci_set_film_type(s,
|
||||||
film_params[s->val[OPT_FILM_TYPE].
|
film_params[s->val[OPT_FILM_TYPE].w]);
|
||||||
w]);
|
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1108,7 +1091,7 @@ e2_set_scanning_parameters(Epson_Scanner * s)
|
||||||
|
|
||||||
/* ESC K, set data order */
|
/* ESC K, set data order */
|
||||||
if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_MIRROR].cap)) {
|
if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_MIRROR].cap)) {
|
||||||
status = esci_mirror_image(s, mirror_params[s->val[OPT_MIRROR].w]);
|
status = esci_mirror_image(s, s->val[OPT_MIRROR].w);
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1164,23 +1147,20 @@ e2_setup_block_mode(Epson_Scanner * s)
|
||||||
__func__, s->lcount);
|
__func__, s->lcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->lcount >= 255) {
|
if (s->lcount >= 255)
|
||||||
s->lcount = 255;
|
s->lcount = 255;
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX why this? */
|
/* XXX why this? */
|
||||||
if (s->hw->TPU && s->hw->use_extension && s->lcount > 32) {
|
if (s->hw->TPU && s->hw->use_extension && s->lcount > 32)
|
||||||
s->lcount = 32;
|
s->lcount = 32;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The D1 series of scanners only allow an even line number
|
* The D1 series of scanners only allow an even line number
|
||||||
* for bi-level scanning. If a bit depth of 1 is selected, then
|
* for bi-level scanning. If a bit depth of 1 is selected, then
|
||||||
* make sure the next lower even number is selected.
|
* make sure the next lower even number is selected.
|
||||||
*/
|
*/
|
||||||
if (s->lcount > 3 && s->lcount % 2) {
|
if (s->lcount > 3 && s->lcount % 2)
|
||||||
s->lcount -= 1;
|
s->lcount -= 1;
|
||||||
}
|
|
||||||
|
|
||||||
DBG(1, "line count is %d\n", s->lcount);
|
DBG(1, "line count is %d\n", s->lcount);
|
||||||
}
|
}
|
||||||
|
@ -1369,9 +1349,9 @@ e2_wait_button(Epson_Scanner * s)
|
||||||
while (s->hw->wait_for_button == SANE_TRUE) {
|
while (s->hw->wait_for_button == SANE_TRUE) {
|
||||||
unsigned char button_status = 0;
|
unsigned char button_status = 0;
|
||||||
|
|
||||||
if (s->canceling == SANE_TRUE) {
|
if (s->canceling == SANE_TRUE)
|
||||||
s->hw->wait_for_button = SANE_FALSE;
|
s->hw->wait_for_button = SANE_FALSE;
|
||||||
}
|
|
||||||
/* get the button status from the scanner */
|
/* get the button status from the scanner */
|
||||||
else if (esci_request_push_button_status(s, &button_status) ==
|
else if (esci_request_push_button_status(s, &button_status) ==
|
||||||
SANE_STATUS_GOOD) {
|
SANE_STATUS_GOOD) {
|
||||||
|
@ -1585,7 +1565,7 @@ void
|
||||||
e2_copy_image_data(Epson_Scanner * s, SANE_Byte * data, SANE_Int max_length,
|
e2_copy_image_data(Epson_Scanner * s, SANE_Byte * data, SANE_Int max_length,
|
||||||
SANE_Int * length)
|
SANE_Int * length)
|
||||||
{
|
{
|
||||||
if (!s->block && SANE_FRAME_RGB == s->params.format) {
|
if (!s->block && s->params.format == SANE_FRAME_RGB) {
|
||||||
|
|
||||||
max_length /= 3;
|
max_length /= 3;
|
||||||
|
|
||||||
|
@ -1594,56 +1574,24 @@ e2_copy_image_data(Epson_Scanner * s, SANE_Byte * data, SANE_Int max_length,
|
||||||
|
|
||||||
*length = 3 * max_length;
|
*length = 3 * max_length;
|
||||||
|
|
||||||
if (s->invert_image == SANE_TRUE) {
|
while (max_length-- != 0) {
|
||||||
while (max_length-- != 0) {
|
*data++ = s->ptr[0];
|
||||||
/* invert the three values */
|
*data++ = s->ptr[s->params.pixels_per_line];
|
||||||
*data++ = (unsigned char) ~(s->ptr[0]);
|
*data++ = s->ptr[2 * s->params.pixels_per_line];
|
||||||
*data++ =
|
++s->ptr;
|
||||||
(unsigned char) ~(s->
|
|
||||||
ptr[s->params.
|
|
||||||
pixels_per_line]);
|
|
||||||
*data++ =
|
|
||||||
(unsigned char) ~(s->
|
|
||||||
ptr[2 *
|
|
||||||
s->params.
|
|
||||||
pixels_per_line]);
|
|
||||||
++s->ptr;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (max_length-- != 0) {
|
|
||||||
*data++ = s->ptr[0];
|
|
||||||
*data++ = s->ptr[s->params.pixels_per_line];
|
|
||||||
*data++ =
|
|
||||||
s->ptr[2 * s->params.pixels_per_line];
|
|
||||||
++s->ptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (max_length > s->end - s->ptr)
|
if (max_length > s->end - s->ptr)
|
||||||
max_length = s->end - s->ptr;
|
max_length = s->end - s->ptr;
|
||||||
|
|
||||||
*length = max_length;
|
*length = max_length;
|
||||||
|
|
||||||
if (1 == s->params.depth) {
|
if (s->params.depth == 1) {
|
||||||
if (s->invert_image == SANE_TRUE) {
|
while (max_length-- != 0)
|
||||||
while (max_length-- != 0)
|
*data++ = ~*s->ptr++;
|
||||||
*data++ = *s->ptr++;
|
|
||||||
} else {
|
|
||||||
while (max_length-- != 0)
|
|
||||||
*data++ = ~*s->ptr++;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
memcpy(data, s->ptr, max_length);
|
||||||
if (s->invert_image == SANE_TRUE) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < max_length; i++) {
|
|
||||||
data[i] =
|
|
||||||
(unsigned char) ~(s->ptr[i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
memcpy(data, s->ptr, max_length);
|
|
||||||
}
|
|
||||||
s->ptr += max_length;
|
s->ptr += max_length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#define EPSON2_VERSION 1
|
#define EPSON2_VERSION 1
|
||||||
#define EPSON2_REVISION 0
|
#define EPSON2_REVISION 0
|
||||||
#define EPSON2_BUILD 121
|
#define EPSON2_BUILD 122
|
||||||
|
|
||||||
/* debugging levels:
|
/* debugging levels:
|
||||||
*
|
*
|
||||||
|
|
|
@ -312,7 +312,6 @@ struct Epson_Scanner
|
||||||
SANE_Bool eof;
|
SANE_Bool eof;
|
||||||
SANE_Byte *buf, *end, *ptr;
|
SANE_Byte *buf, *end, *ptr;
|
||||||
SANE_Bool canceling;
|
SANE_Bool canceling;
|
||||||
SANE_Bool invert_image;
|
|
||||||
SANE_Bool focusOnGlass;
|
SANE_Bool focusOnGlass;
|
||||||
SANE_Byte currentFocusPosition;
|
SANE_Byte currentFocusPosition;
|
||||||
/* SANE_Word gamma_table [ 4] [ 256]; */
|
/* SANE_Word gamma_table [ 4] [ 256]; */
|
||||||
|
|
Ładowanie…
Reference in New Issue