aboutsummaryrefslogtreecommitdiffstats
path: root/thumbs.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-17 15:58:11 +0100
committerBert <ber.t@gmx.com>2011-02-17 15:58:11 +0100
commit095217b26f43b711c8ebc281110553ec788f7ebe (patch)
treeaf8aab21420d8be7739ff43239e94b0a46133da7 /thumbs.c
parentdc04bdc72f87a3f1ec3efe0aaaabbb3ca1455644 (diff)
downloadnsxiv-095217b26f43b711c8ebc281110553ec788f7ebe.tar.zst
Linked thumbnails to files
Diffstat (limited to 'thumbs.c')
-rw-r--r--thumbs.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/thumbs.c b/thumbs.c
index bac00d9..e66dd1c 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -25,6 +25,7 @@
#include "thumbs.h"
#include "util.h"
+extern Imlib_Image *im_broken;
const int thumb_dim = THUMB_SIZE + 10;
void tns_init(tns_t *tns, int cnt) {
@@ -57,19 +58,20 @@ void tns_load(tns_t *tns, win_t *win, const char *filename) {
if (!tns || !win || !filename)
return;
- if (!(im = imlib_load_image(filename)))
- return;
-
- imlib_context_set_image(im);
+ if ((im = imlib_load_image(filename)))
+ imlib_context_set_image(im);
+ else
+ imlib_context_set_image(im_broken);
w = imlib_image_get_width();
h = imlib_image_get_height();
zw = (float) THUMB_SIZE / (float) w;
zh = (float) THUMB_SIZE / (float) h;
z = MIN(zw, zh);
+ if (!im && z > 1.0)
+ z = 1.0;
t = &tns->thumbs[tns->cnt++];
- t->filename = filename;
t->w = z * w;
t->h = z * h;