From c2a83ec948ffb5604e30cb9cba4f6b71b5ad2b43 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Sat, 27 Oct 2007 14:45:14 +0100 Subject: [PATCH] Improved image dimension handling Drivers now specify the size of the image they provide, and theres an API so that you can get the size of an image before you capture it. --- libfprint/drivers/uru4000.c | 7 +++---- libfprint/fp_internal.h | 2 ++ libfprint/fprint.h | 2 ++ libfprint/imgdev.c | 21 +++++++++++++++++++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/libfprint/drivers/uru4000.c b/libfprint/drivers/uru4000.c index 56e5027..f11aa89 100644 --- a/libfprint/drivers/uru4000.c +++ b/libfprint/drivers/uru4000.c @@ -39,8 +39,6 @@ #define DATABLK2_EXPECT 0xb1c0 #define CAPTURE_HDRLEN 64 #define IRQ_LENGTH 64 -#define IMG_WIDTH 384 -#define IMG_HEIGHT 289 enum { IRQDATA_SCANPWR_ON = 0x56aa, @@ -292,8 +290,6 @@ static int capture(struct fp_img_dev *dev, gboolean unconditional, /* remove header and shrink allocation */ g_memmove(img->data, img->data + CAPTURE_HDRLEN, image_size); img = fpi_img_resize(img, image_size); - img->width = IMG_WIDTH; - img->height = IMG_HEIGHT; img->flags = FP_IMG_V_FLIPPED | FP_IMG_H_FLIPPED | FP_IMG_COLORS_INVERTED; *ret = img; @@ -498,6 +494,9 @@ struct fp_img_driver uru4000_driver = { .id_table = id_table, }, .flags = FP_IMGDRV_SUPPORTS_UNCONDITIONAL_CAPTURE, + .img_height = 289, + .img_width = 384, + .init = dev_init, .exit = dev_exit, .await_finger_on = await_finger_on, diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h index 537b0d9..47eea27 100644 --- a/libfprint/fp_internal.h +++ b/libfprint/fp_internal.h @@ -125,6 +125,8 @@ struct fp_driver { struct fp_img_driver { struct fp_driver driver; uint16_t flags; + int img_width; + int img_height; /* Device operations */ int (*init)(struct fp_img_dev *dev, unsigned long driver_data); diff --git a/libfprint/fprint.h b/libfprint/fprint.h index 541e976..8a10a90 100644 --- a/libfprint/fprint.h +++ b/libfprint/fprint.h @@ -91,6 +91,8 @@ void fp_print_data_free(struct fp_print_data *data); /* Imaging devices */ int fp_imgdev_capture(struct fp_img_dev *imgdev, int unconditional, struct fp_img **image); +int fp_imgdev_get_img_width(struct fp_img_dev *imgdev); +int fp_imgdev_get_img_height(struct fp_img_dev *imgdev); /* Image handling */ int fp_img_get_height(struct fp_img *img); diff --git a/libfprint/imgdev.c b/libfprint/imgdev.c index be48b86..e1f4c3a 100644 --- a/libfprint/imgdev.c +++ b/libfprint/imgdev.c @@ -61,6 +61,20 @@ static void img_dev_exit(struct fp_dev *dev) g_free(imgdev); } +API_EXPORTED int fp_imgdev_get_img_width(struct fp_img_dev *imgdev) +{ + struct fp_driver *drv = imgdev->dev->drv; + struct fp_img_driver *imgdrv = driver_to_img_driver(drv); + return imgdrv->img_width; +} + +API_EXPORTED int fp_imgdev_get_img_height(struct fp_img_dev *imgdev) +{ + struct fp_driver *drv = imgdev->dev->drv; + struct fp_img_driver *imgdrv = driver_to_img_driver(drv); + return imgdrv->img_height; +} + API_EXPORTED int fp_imgdev_capture(struct fp_img_dev *imgdev, int unconditional, struct fp_img **image) { @@ -111,11 +125,14 @@ API_EXPORTED int fp_imgdev_capture(struct fp_img_dev *imgdev, } if (r == 0) { - if (*image == NULL) { + struct fp_img *img = *image; + if (img == NULL) { fp_err("capture succeeded but no image returned?"); return -ENODATA; } - if (!fpi_img_is_sane(*image)) { + img->width = imgdrv->img_width; + img->height = imgdrv->img_height; + if (!fpi_img_is_sane(img)) { fp_err("image is not sane!"); return -EIO; }