gl847 scan quality improvement

- improve scan quality by doubling x resolution internally at low dpi
- tune y offset of scan area
merge-requests/1/head
Stphane Voltz 2010-06-20 22:04:51 +02:00
rodzic bae05c312a
commit 9f6fd50dfc
5 zmienionych plików z 91 dodań i 39 usunięć

Wyświetl plik

@ -1,3 +1,8 @@
2010-06-20 Stéphane Voltz <stef.dev@free.fr>
* backend/genesys.c backend/genesys_devices.c backend/genesys_gl847.c
backend/genesys_low.h: improve scan quality by using double x
resolution internally at low resolution
2010-06-18 Stéphane Voltz <stef.dev@free.fr>
* backend/genesys.c backend/genesys_devices.c backend/genesys_gl847.c:
add 400, 200 and 100 dpi resolution to LiDE 100 and LiDE 200 . Disable

Wyświetl plik

@ -3024,6 +3024,11 @@ compute_averaged_planar (Genesys_Device * dev,
/* scanner is using half-ccd mode */
res *= 2;
}
if (dev->settings.double_xres == SANE_TRUE)
{
/* scanner is using double x resolution */
res *= 2;
}
/* this should be evenly dividable */
avgpixels = dev->sensor.optical_res / res;
@ -5057,44 +5062,50 @@ genesys_fill_read_buffer (Genesys_Device * dev)
count = 0;
while (count < size)
{
while (dev->cur < dev->len && count < size)
{
if(dev->settings.depth==8)
{
/* even pixel */
work_buffer_dst[count] =
dev->oe_buffer.buffer[dev->cur + dev->skip + dev->oe_buffer.pos];
/* odd pixel */
work_buffer_dst[count + 1] =
dev->oe_buffer.buffer[dev->cur + dev->skip + dev->dist +
dev->oe_buffer.pos];
count += 2;
dev->cur++;
if(dev->settings.double_xres==SANE_TRUE)
{
/* copy only even pixel */
work_buffer_dst[count] = dev->oe_buffer.buffer[dev->cur + dev->skip + dev->oe_buffer.pos];
/* update counter and pointer */
count++;
dev->cur++;
}
else if(dev->settings.depth==8 && dev->settings.double_xres==SANE_FALSE)
{
while (dev->cur < dev->len && count < size)
{
/* copy even pixel */
work_buffer_dst[count] = dev->oe_buffer.buffer[dev->cur + dev->skip + dev->oe_buffer.pos];
/* copy odd pixel */
work_buffer_dst[count + 1] = dev->oe_buffer.buffer[dev->cur + dev->skip + dev->dist + dev->oe_buffer.pos];
/* update counter and pointer */
count += 2;
dev->cur++;
}
else
{
/* even pixel */
work_buffer_dst[count] =
dev->oe_buffer.buffer[dev->cur + dev->skip + dev->oe_buffer.pos];
work_buffer_dst[count+1] =
dev->oe_buffer.buffer[dev->cur + dev->skip + dev->oe_buffer.pos+1];
/* odd pixel */
work_buffer_dst[count + 2] =
dev->oe_buffer.buffer[dev->cur + dev->skip + dev->dist +
dev->oe_buffer.pos];
work_buffer_dst[count + 3] =
dev->oe_buffer.buffer[dev->cur + dev->skip + dev->dist +
dev->oe_buffer.pos+1];
count += 4;
dev->cur+=2;
}
else if(dev->settings.depth==16 && dev->settings.double_xres==SANE_FALSE)
{
while (dev->cur < dev->len && count < size)
{
/* copy even pixel */
work_buffer_dst[count] = dev->oe_buffer.buffer[dev->cur + dev->skip + dev->oe_buffer.pos];
work_buffer_dst[count+1] = dev->oe_buffer.buffer[dev->cur + dev->skip + dev->oe_buffer.pos+1];
/* copy odd pixel */
work_buffer_dst[count + 2] = dev->oe_buffer.buffer[dev->cur + dev->skip + dev->dist + dev->oe_buffer.pos];
work_buffer_dst[count + 3] = dev->oe_buffer.buffer[dev->cur + dev->skip + dev->dist + dev->oe_buffer.pos+1];
/* update counter and pointer */
count += 4;
dev->cur+=2;
}
}
}
/* go to next line if needed */
if (dev->cur == dev->len)
{
dev->oe_buffer.pos += dev->bpl;
dev->cur = 0;
}
/* read a new buffer if needed */
if (dev->oe_buffer.pos >= dev->oe_buffer.avail)
{
@ -5725,7 +5736,7 @@ calc_parameters (Genesys_Scanner * s)
s->dev->settings.disable_interpolation =
s->val[OPT_DISABLE_INTERPOLATION].w == SANE_TRUE;
/* Hardware settings */
/* hardware settings */
if (resolution > s->dev->sensor.optical_res &&
s->dev->settings.disable_interpolation)
s->dev->settings.xres = s->dev->sensor.optical_res;
@ -5733,10 +5744,19 @@ calc_parameters (Genesys_Scanner * s)
s->dev->settings.xres = resolution;
s->dev->settings.yres = resolution;
/* double x resolution mode */
s->dev->settings.double_xres = SANE_FALSE;
if ((s->dev->model->flags & GENESYS_FLAG_ODD_EVEN_CIS)
&& s->dev->settings.xres <= s->dev->sensor.optical_res / 2
&& s->dev->settings.xres != 400)
{
s->dev->settings.double_xres = SANE_TRUE;
}
s->params.lines = ((br_y - tl_y) * s->dev->settings.yres) / MM_PER_INCH;
s->params.pixels_per_line =
((br_x - tl_x) * s->dev->settings.xres) / MM_PER_INCH;
/* we need an even number of pixels for even/odd handling */
if (s->dev->model->flags & GENESYS_FLAG_ODD_EVEN_CIS)
{

Wyświetl plik

@ -922,13 +922,13 @@ static Genesys_Model canon_lide_100_model = {
GENESYS_GL847,
NULL,
{1200, 600, 400, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions 400 & 100 dpi are ok too */
{1200, 600, 400, 300, 200, 150, 100, 75, 0}, /* possible x-resolutions */
{1200, 600, 400, 300, 200, 150, 100, 75, 0}, /* possible y-resolutions */
{16, 8, 0}, /* possible depths in gray mode */
{16, 8, 0}, /* possible depths in color mode */
SANE_FIX (0.0), /* Start of scan area in mm (x) */
SANE_FIX (7.3), /* Start of scan area in mm (y) */
SANE_FIX (8.3), /* Start of scan area in mm (y) */
SANE_FIX (216.07), /* Size of scan area in mm (x) */
SANE_FIX (299.0), /* Size of scan area in mm (y) */
@ -981,7 +981,7 @@ static Genesys_Model canon_lide_200_model = {
{16, 8, 0}, /* possible depths in color mode */
SANE_FIX (0.0), /* Start of scan area in mm (x) */
SANE_FIX (7.3), /* Start of scan area in mm (y) */
SANE_FIX (8.3), /* Start of scan area in mm (y) */
SANE_FIX (216.07), /* Size of scan area in mm (x) */
SANE_FIX (299.0), /* Size of scan area in mm (y) */

Wyświetl plik

@ -1426,11 +1426,12 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
SANE_Bool half_ccd, int color_filter, int flags)
{
unsigned int words_per_line;
unsigned int startx,endx, used_pixels;
unsigned int startx,endx, used_pixels,max_pixels;
unsigned int dpiset;
unsigned int i,bytes;
Genesys_Register_Set *r;
SANE_Status status;
int double_xres;
DBG (DBG_proc, "gl847_init_optical_regs_scan : exposure_time=%d, "
"used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, "
@ -1438,10 +1439,28 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
exposure_time,
used_res, start, pixels, channels, depth, half_ccd, flags);
startx = dev->sensor.dummy_pixel + 1 + dev->sensor.CCD_start_xoffset;
if(pixels<dev->sensor.sensor_pixels)
/* during calibration , we don't want double xres */
if(dev->settings.double_xres==SANE_TRUE&&used_res<dev->sensor.optical_res)
{
used_pixels = dev->sensor.sensor_pixels;
double_xres=SANE_TRUE;
}
else
{
double_xres=SANE_FALSE;
}
startx = dev->sensor.dummy_pixel + 1 + dev->sensor.CCD_start_xoffset;
if(double_xres==SANE_TRUE)
{
max_pixels = dev->sensor.sensor_pixels/2;
}
else
{
max_pixels = dev->sensor.sensor_pixels;
}
if(pixels<max_pixels)
{
used_pixels = max_pixels;
}
else
{
@ -1460,6 +1479,10 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
/* adjust used_res for chosen dpihw */
used_res = used_res * gl847_get_dpihw (dev) / dev->sensor.optical_res;
if(double_xres==SANE_TRUE)
{
used_res *=2;
}
dpiset = used_res;
/* enable shading */
@ -1599,7 +1622,7 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
dev->len=((pixels*dpiset)/gl847_get_dpihw (dev))/2*bytes;
dev->dist=dev->bpl/2;
dev->skip=((start*dpiset)/gl847_get_dpihw (dev))/2*bytes;
if(dev->skip>=dev->dist)
if(dev->skip>=dev->dist && double_xres==SANE_FALSE)
{
dev->skip-=dev->dist;
}

Wyświetl plik

@ -532,6 +532,10 @@ typedef struct
/**> Disable interpolation for xres<yres*/
int disable_interpolation;
/**> Use double x resolution internally to provide better
* quality */
int double_xres;
/**> true is lineart is generated from gray data by
* the dynamic rasterization algo */
int dynamic_lineart;