Revert "Correction of the zone cropping."

This reverts commit 67c7ef9c4e.
merge-requests/213/head^2
Thierry HUCHARD 2020-03-29 21:37:25 +02:00
rodzic 67c7ef9c4e
commit 062fb40cf4
1 zmienionych plików z 13 dodań i 20 usunięć

Wyświetl plik

@ -48,44 +48,37 @@ escl_crop_surface(capabilities_t *scanner,
scanner->width = w;
if (scanner->pos_x < 0)
scanner->pos_x = 0;
if (scanner->width > scanner->pos_x)
x_off = scanner->pos_x;
real_w = scanner->width - x_off;
if (h < (int)scanner->height)
scanner->height = h;
if (scanner->pos_y < 0)
scanner->pos_y = 0;
if (scanner->pos_y < scanner->height)
y_off = scanner->pos_y;
real_h = scanner->height - y_off;
if (scanner->pos_x < 0)
scanner->pos_x = 0;
x_off = scanner->pos_x;
real_w = scanner->width - x_off;
y_off = scanner->pos_y;
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
* real_h * bps);
if(!surface_crop) {
if(!surface_crop) {
DBG( 1, "Escl Crop : Surface_crop Memory allocation problem\n");
free(surface);
surface = NULL;
goto finish;
}
free(surface);
surface = NULL;
goto finish;
}
for (y = 0; y < real_h; y++)
{
for (x = 0; x < real_w; x++)
{
surface_crop[(y * real_w * bps) + (x * bps)] =
surface[((y + y_off) * w * bps) + ((x + x_off) * bps)];
surface_crop[(y * real_w * bps) + (x * bps) + 1] =
surface[((y + y_off) * w * bps) + ((x + x_off) * bps) + 1];
surface_crop[(y * real_w * bps) + (x * bps) + 2] =
surface[((y + y_off) * w * bps) + ((x + x_off) * bps) + 2];
surface_crop[y * real_w + x] = surface[(y + y_off) * w + x + x_off];
}
}
free(surface);
surface = surface_crop;
surface = surface_crop;
}
// we don't need row pointers anymore
scanner->img_data = surface;