mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
assembling: Fix copying only partial tile on overhang
If the tile in question was hanging over the left edge we would not be copying the full available width. Fix this and change the test to catch the error condition (by forcing a too small image and overlap both ways). Simplify the code by only selecting the starting point inside the image/frame and then just checking the both image and frame boundary in the loop. Not quite as efficient, but it really shouldn't matter too much here.
This commit is contained in:
@@ -62,6 +62,7 @@ test_frame_assembling (void)
|
||||
int test_height;
|
||||
guchar *data;
|
||||
struct fpi_frame_asmbl_ctx ctx = { 0, };
|
||||
gint xborder = 5;
|
||||
|
||||
g_autoptr(FpImage) fp_img = NULL;
|
||||
GSList *frames = NULL;
|
||||
@@ -79,7 +80,7 @@ test_frame_assembling (void)
|
||||
ctx.get_pixel = cairo_get_pixel;
|
||||
ctx.frame_width = width;
|
||||
ctx.frame_height = 20;
|
||||
ctx.image_width = width;
|
||||
ctx.image_width = width - 2 * xborder;
|
||||
|
||||
g_assert (height > ctx.frame_height);
|
||||
|
||||
@@ -118,8 +119,8 @@ test_frame_assembling (void)
|
||||
|
||||
/* The FpImage and cairo surface need to be identical in the test area */
|
||||
for (int y = 0; y < test_height; y++)
|
||||
for (int x = 0; x < width; x++)
|
||||
g_assert_cmpint (data[x * 4 + y * stride + 1], ==, fp_img->data[x + y * width]);
|
||||
for (int x = 0; x < ctx.image_width; x++)
|
||||
g_assert_cmpint (data[(x + xborder) * 4 + y * stride + 1], ==, fp_img->data[x + y * ctx.image_width]);
|
||||
|
||||
g_slist_free_full (frames, g_free);
|
||||
cairo_surface_destroy (img);
|
||||
|
||||
Reference in New Issue
Block a user