From 637be490753ff107e1c43a1c69a786ada6b02e2c Mon Sep 17 00:00:00 2001 From: Bert Date: Fri, 18 Feb 2011 15:02:49 +0100 Subject: Nicer tns_translate --- thumbs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/thumbs.c b/thumbs.c index 2b77458..3f187fc 100644 --- a/thumbs.c +++ b/thumbs.c @@ -181,9 +181,11 @@ int tns_translate(tns_t *tns, int x, int y) { if (!tns || x < tns->x || y < tns->y) return -1; - if ((n = (y - tns->y) / thumb_dim * tns->cols + (x - tns->x) / thumb_dim) < tns->cnt) { + n = (y - tns->y) / thumb_dim * tns->cols + (x - tns->x) / thumb_dim; + + if (n < tns->cnt) { t = &tns->thumbs[n]; - if (x > t->x && x < t->x + t->w && y > t->y && y < t->y + t->h) + if (x >= t->x && x <= t->x + t->w && y >= t->y && y <= t->y + t->h) return n; } -- cgit v1.2.3-54-g00ecf