Merge branch 'escl-fix-ratio-crop' into 'master'

Escl fix ratio crop

See merge request sane-project/backends!390
merge-requests/213/head^2
Ordissimo 2020-04-02 09:08:24 +00:00
commit 911e40ba4e
2 zmienionych plików z 22 dodań i 11 usunięć

Wyświetl plik

@ -889,8 +889,18 @@ sane_start(SANE_Handle h)
}
handler->scanner->height = MM_TO_PIXEL(handler->val[OPT_BR_Y].w, 300.0);
handler->scanner->width = MM_TO_PIXEL(handler->val[OPT_BR_X].w, 300.0);
handler->scanner->pos_x = MM_TO_PIXEL(handler->val[OPT_TL_X].w, 300.0);
handler->scanner->pos_y = MM_TO_PIXEL(handler->val[OPT_TL_Y].w, 300.0);
if (handler->x_range.min == handler->val[OPT_TL_X].w)
handler->scanner->pos_x = 0;
else
handler->scanner->pos_x = MM_TO_PIXEL(
(handler->val[OPT_TL_X].w - handler->x_range.min),
300.0);
if (handler->y_range.min == handler->val[OPT_TL_Y].w)
handler->scanner->pos_y = 0;
else
handler->scanner->pos_y = MM_TO_PIXEL(
(handler->val[OPT_TL_Y].w - handler->y_range.min),
300.0);
DBG(10, "Calculate Size Image [%dx%d|%dx%d]\n",
handler->scanner->pos_x,
handler->scanner->pos_y,

Wyświetl plik

@ -37,6 +37,7 @@ escl_crop_surface(capabilities_t *scanner,
int *width,
int *height)
{
double ratio = 1.0;
int x_off = 0, x = 0;
int real_w = 0;
int y_off = 0, y = 0;
@ -44,24 +45,24 @@ escl_crop_surface(capabilities_t *scanner,
unsigned char *surface_crop = NULL;
DBG( 1, "Escl Image Crop\n");
if (w < (int)scanner->width)
scanner->width = w;
ratio = (double)w / (double)scanner->width;
scanner->width = w;
if (scanner->pos_x < 0)
scanner->pos_x = 0;
if (scanner->width > scanner->pos_x)
x_off = scanner->pos_x;
if (scanner->pos_x && scanner->width > scanner->pos_x)
x_off = (int)((double)scanner->pos_x * ratio);
real_w = scanner->width - x_off;
if (h < (int)scanner->height)
scanner->height = h;
scanner->height = h;
if (scanner->pos_y < 0)
scanner->pos_y = 0;
if (scanner->pos_y < scanner->height)
y_off = scanner->pos_y;
scanner->pos_y = 0;
if (scanner->pos_y && scanner->pos_y < scanner->height)
y_off = (int)((double)scanner->pos_y * ratio);
real_h = scanner->height - y_off;
*width = real_w;
*height = real_h;
if (x_off > 0 || real_w < scanner->width ||
y_off > 0 || real_h < scanner->height) {
surface_crop = (unsigned char *)malloc (sizeof (unsigned char) * real_w