kopia lustrzana https://gitlab.com/sane-project/backends
Correction of the zone cropping.
rodzic
c6a8a54111
commit
d06e42b08c
|
@ -48,37 +48,44 @@ 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_x < 0)
|
||||
scanner->pos_x = 0;
|
||||
|
||||
x_off = scanner->pos_x;
|
||||
real_w = scanner->width - x_off;
|
||||
y_off = scanner->pos_y;
|
||||
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;
|
||||
|
||||
*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 + x] = surface[(y + y_off) * w + x + x_off];
|
||||
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];
|
||||
}
|
||||
}
|
||||
free(surface);
|
||||
surface = surface_crop;
|
||||
surface = surface_crop;
|
||||
}
|
||||
// we don't need row pointers anymore
|
||||
scanner->img_data = surface;
|
||||
|
|
Ładowanie…
Reference in New Issue