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.
This commit is contained in:
parent
9960a7ff34
commit
c2a83ec948
4 changed files with 26 additions and 6 deletions
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue