canon_dr v53 continued

reorder geometry group options
use bg_color to fill missing image data
merge-requests/1/head
m. allan noah 2015-11-06 21:39:35 -05:00
rodzic 398610336b
commit 358cbd7f31
2 zmienionych plików z 47 dodań i 58 usunięć

Wyświetl plik

@ -325,6 +325,8 @@
v53 2015-11-06, MAN
- replace image processing methods with sanei_magic
- add swskip option
- reorder geometry group options
- use bg_color to fill missing image data
SANE FLOW DIAGRAM
@ -4799,23 +4801,7 @@ read_from_scanner(struct scanner *s, int side, int exact)
/* this is non-jpeg data, fill remainder, change rx'd size */
else{
DBG (15, "read_from_scanner: eof: %d %d\n", s->i.bytes_tot[side], s->i.bytes_sent[side]);
/* clone the last line repeatedly until the end */
while(s->i.bytes_tot[side] > s->i.bytes_sent[side]){
memcpy(
s->buffers[side]+s->i.bytes_sent[side]-s->i.Bpl,
s->buffers[side]+s->i.bytes_sent[side],
s->i.Bpl
);
s->i.bytes_sent[side] += s->i.Bpl;
}
DBG (15, "read_from_scanner: eof2: %d %d\n", s->i.bytes_tot[side], s->i.bytes_sent[side]);
/* pretend we got all the data from scanner */
s->s.bytes_sent[side] = s->s.bytes_tot[side];
fill_image(s,side);
}
s->i.eof[side] = 1;
@ -4937,40 +4923,8 @@ read_from_scanner_duplex(struct scanner *s,int exact)
/* this is non-jpeg data, fill remainder, change rx'd size */
else{
DBG (15, "read_from_scanner_duplex: eof: %d %d %d %d\n",
s->i.bytes_tot[SIDE_FRONT], s->i.bytes_sent[SIDE_FRONT],
s->i.bytes_tot[SIDE_BACK], s->i.bytes_sent[SIDE_BACK]
);
/* clone the last line repeatedly until the end */
while(s->i.bytes_tot[SIDE_FRONT] > s->i.bytes_sent[SIDE_FRONT]){
memcpy(
s->buffers[SIDE_FRONT]+s->i.bytes_sent[SIDE_FRONT]-s->i.Bpl,
s->buffers[SIDE_FRONT]+s->i.bytes_sent[SIDE_FRONT],
s->i.Bpl
);
s->i.bytes_sent[SIDE_FRONT] += s->i.Bpl;
}
/* clone the last line repeatedly until the end */
while(s->i.bytes_tot[SIDE_BACK] > s->i.bytes_sent[SIDE_BACK]){
memcpy(
s->buffers[SIDE_BACK]+s->i.bytes_sent[SIDE_BACK]-s->i.Bpl,
s->buffers[SIDE_BACK]+s->i.bytes_sent[SIDE_BACK],
s->i.Bpl
);
s->i.bytes_sent[SIDE_BACK] += s->i.Bpl;
}
DBG (15, "read_from_scanner_duplex: eof2: %d %d %d %d\n",
s->i.bytes_tot[SIDE_FRONT], s->i.bytes_sent[SIDE_FRONT],
s->i.bytes_tot[SIDE_BACK], s->i.bytes_sent[SIDE_BACK]
);
/* pretend we got all the data from scanner */
s->s.bytes_sent[SIDE_FRONT] = s->s.bytes_tot[SIDE_FRONT];
s->s.bytes_sent[SIDE_BACK] = s->s.bytes_tot[SIDE_BACK];
fill_image(s,SIDE_FRONT);
fill_image(s,SIDE_BACK);
}
s->i.eof[SIDE_FRONT] = 1;
@ -5496,6 +5450,43 @@ read_from_buffer(struct scanner *s, SANE_Byte * buf, SANE_Int max_len,
return ret;
}
/* fill remainder of buffer with background if scanner stops early */
static SANE_Status
fill_image(struct scanner *s,int side)
{
SANE_Status ret=SANE_STATUS_GOOD;
unsigned char bg_color = calc_bg_color(s);
int fill_bytes = s->i.bytes_tot[side]-s->i.bytes_sent[side];
if(!fill_bytes){
return ret;
}
DBG (15, "fill_image: side:%d bytes:%d bg_color:%02x\n", side, fill_bytes, bg_color);
/* fill the rest with bg_color */
memset(s->buffers[side]+s->i.bytes_sent[side],bg_color,fill_bytes);
/* pretend we got all the data from scanner */
s->i.bytes_sent[side] = s->i.bytes_tot[side];
s->s.bytes_sent[side] = s->s.bytes_tot[side];
return ret;
}
/* return the bg color based on scanner settings */
static unsigned char
calc_bg_color(struct scanner *s)
{
unsigned char bg_color = s->lut[s->bg_color];
if(s->u.mode <= MODE_HALFTONE)
bg_color = (bg_color<s->threshold)?0xff:0x00;
return bg_color;
}
/*
* @@ Section 5 - calibration functions
*/
@ -7436,14 +7427,10 @@ buffer_deskew(struct scanner *s, int side)
{
SANE_Status ret = SANE_STATUS_GOOD;
int bg_color = s->lut[s->bg_color];
unsigned char bg_color = calc_bg_color(s);
DBG (10, "buffer_deskew: start\n");
/* tweak the bg color based on scanner settings */
if(s->u.mode == MODE_HALFTONE || s->u.mode == MODE_LINEART)
bg_color = (bg_color<s->threshold)?0xff:0x00;
ret = sane_get_parameters((SANE_Handle) s, &s->s_params);
/*only find skew on first image from a page, or if first image had error */

Wyświetl plik

@ -21,12 +21,12 @@ enum scanner_Option
OPT_RES, /*a range or a list*/
OPT_GEOMETRY_GROUP,
OPT_PAGE_WIDTH,
OPT_PAGE_HEIGHT,
OPT_TL_X,
OPT_TL_Y,
OPT_BR_X,
OPT_BR_Y,
OPT_PAGE_WIDTH,
OPT_PAGE_HEIGHT,
OPT_ENHANCEMENT_GROUP,
OPT_BRIGHTNESS,
@ -583,9 +583,11 @@ static SANE_Status read_from_scanner_duplex(struct scanner *s, int exact);
static SANE_Status copy_simplex(struct scanner *s, unsigned char * buf, int len, int side);
static SANE_Status copy_duplex(struct scanner *s, unsigned char * buf, int len);
static SANE_Status copy_line(struct scanner *s, unsigned char * buf, int side);
static SANE_Status fill_image(struct scanner *s,int side);
static int must_downsample (struct scanner *s);
static int must_fully_buffer (struct scanner *s);
static unsigned char calc_bg_color(struct scanner *s);
static SANE_Status buffer_despeck(struct scanner *s, int side);
static SANE_Status buffer_deskew(struct scanner *s, int side);