merge-requests/213/head^2
Thierry HUCHARD 2020-03-14 16:19:18 +01:00
rodzic 1b3f0c9bc0
commit 749fe19feb
5 zmienionych plików z 36 dodań i 36 usunięć

Wyświetl plik

@ -833,7 +833,7 @@ escl_add_in_list(ESCL_Device *current)
}
else if (!strcmp(handler->scanner->caps[handler->scanner->source].default_format, "application/pdf"))
{
status = get_PDF_data(handler->caps[handler->scanner->source].scanner, &w, &he, &bps);
status = get_PDF_data(handler->scanner, &w, &he, &bps);
}
else {
DBG(10, "Unknow image format\n");

Wyświetl plik

@ -213,11 +213,11 @@ find_valor_of_array_variables(xmlNode *node, capabilities_t *scanner, int type)
}
#endif
#if(defined HAVE_POPPLER_GLIB)
else if(!strcmp(scanner->DocumentFormats[i], "application/pdf"))
else if(!strcmp(scanner->caps[scanner->source].DocumentFormats[i], "application/pdf"))
{
if (scanner->default_format)
free(scanner->default_format);
scanner->default_format = strdup("application/pdf");
if (scanner->caps[scanner->source].default_format)
free(scanner->caps[scanner->source].default_format);
scanner->caps[scanner->source].default_format = strdup("application/pdf");
}
#endif
}

Wyświetl plik

@ -44,24 +44,24 @@ escl_crop_surface(capabilities_t *scanner,
unsigned char *surface_crop = NULL;
DBG( 1, "Escl Image Crop\n");
if (w < (int)scanner->caps[s->scanner->source].width)
scanner->caps[s->scanner->source].width = w;
if (scanner->caps[s->scanner->source].pos_x < 0)
scanner->caps[s->scanner->source].pos_x = 0;
if (w < (int)scanner->caps[scanner->source].width)
scanner->caps[scanner->source].width = w;
if (scanner->caps[scanner->source].pos_x < 0)
scanner->caps[scanner->source].pos_x = 0;
if (h < (int)scanner->caps[s->scanner->source].height)
scanner->caps[s->scanner->source].height = h;
if (scanner->caps[s->scanner->source].pos_x < 0)
scanner->caps[s->scanner->source].pos_x = 0;
if (h < (int)scanner->caps[scanner->source].height)
scanner->caps[scanner->source].height = h;
if (scanner->caps[scanner->source].pos_x < 0)
scanner->caps[scanner->source].pos_x = 0;
x_off = scanner->caps[s->scanner->source].pos_x;
real_w = scanner->caps[s->scanner->source].width - x_off;
y_off = scanner->caps[s->scanner->source].pos_y;
real_h = scanner->caps[s->scanner->source].height - y_off;
x_off = scanner->caps[scanner->source].pos_x;
real_w = scanner->caps[scanner->source].width - x_off;
y_off = scanner->caps[scanner->source].pos_y;
real_h = scanner->caps[scanner->source].height - y_off;
*width = real_w;
*height = real_h;
if (x_off > 0 || real_w < scanner->caps[s->scanner->source].width ||
y_off > 0 || real_h < scanner->caps[s->scanner->source].height) {
if (x_off > 0 || real_w < scanner->caps[scanner->source].width ||
y_off > 0 || real_h < scanner->caps[scanner->source].height) {
surface_crop = (unsigned char *)malloc (sizeof (unsigned char) * real_w
* real_h * bps);
if(!surface_crop) {

Wyświetl plik

@ -193,20 +193,20 @@ get_JPEG_data(capabilities_t *scanner, int *width, int *height, int *bps)
cinfo.out_color_space = JCS_RGB;
cinfo.quantize_colors = FALSE;
jpeg_calc_output_dimensions(&cinfo);
if (cinfo.output_width < (unsigned int)scanner->caps[s->scanner->source].width)
scanner->caps[s->scanner->source].width = cinfo.output_width;
if (scanner->caps[s->scanner->source].pos_x < 0)
scanner->caps[s->scanner->source].pos_x = 0;
if (cinfo.output_width < (unsigned int)scanner->caps[scanner->source].width)
scanner->caps[scanner->source].width = cinfo.output_width;
if (scanner->caps[scanner->source].pos_x < 0)
scanner->caps[scanner->source].pos_x = 0;
if (cinfo.output_height < (unsigned int)scanner->caps[s->scanner->source].height)
scanner->caps[s->scanner->source].height = cinfo.output_height;
if (scanner->caps[s->scanner->source].pos_y < 0)
scanner->caps[s->scanner->source].pos_y = 0;
if (cinfo.output_height < (unsigned int)scanner->caps[scanner->source].height)
scanner->caps[scanner->source].height = cinfo.output_height;
if (scanner->caps[scanner->source].pos_y < 0)
scanner->caps[scanner->source].pos_y = 0;
x_off = scanner->caps[s->scanner->source].pos_x;
w = scanner->caps[s->scanner->source].width - x_off;
y_off = scanner->caps[s->scanner->source].pos_y;
h = scanner->caps[s->scanner->source].height - y_off;
x_off = scanner->caps[scanner->source].pos_x;
w = scanner->caps[scanner->source].width - x_off;
y_off = scanner->caps[scanner->source].pos_y;
h = scanner->caps[scanner->source].height - y_off;
surface = malloc(w * h * cinfo.output_components);
if (surface == NULL) {
jpeg_destroy_decompress(&cinfo);
@ -224,7 +224,7 @@ get_JPEG_data(capabilities_t *scanner, int *width, int *height, int *bps)
if (y_off > 0)
jpeg_skip_scanlines(&cinfo, y_off);
pos = 0;
while (cinfo.output_scanline < (unsigned int)scanner->caps[s->scanner->source].height) {
while (cinfo.output_scanline < (unsigned int)scanner->caps[scanner->source].height) {
rowptr[0] = (JSAMPROW)surface + (lineSize * pos); // ..cinfo.output_scanline);
jpeg_read_scanlines(&cinfo, rowptr, (JDIMENSION) 1);
pos++;

Wyświetl plik

@ -140,8 +140,8 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
}
poppler_page_get_size (page, &dw, &dh);
dw = (double)scanner->default_resolution * dw / 72.0;
dh = (double)scanner->default_resolution * dh / 72.0;
dw = (double)scanner->caps[scanner->source].default_resolution * dw / 72.0;
dh = (double)scanner->caps[scanner->source].default_resolution * dh / 72.0;
w = (int)ceil(dw);
h = (int)ceil(dh);
cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h);
@ -157,8 +157,8 @@ get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps)
status = SANE_STATUS_INVAL;
goto free_surface;
}
cairo_scale (cr, (double)scanner->default_resolution / 72.0,
(double)scanner->default_resolution / 72.0);
cairo_scale (cr, (double)scanner->caps[scanner->source].default_resolution / 72.0,
(double)scanner->caps[scanner->source].default_resolution / 72.0);
cairo_save (cr);
poppler_page_render (page, cr);
cairo_restore (cr);