|
|
|
@ -152,7 +152,7 @@ void tns_clean_cache(tns_t *tns)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void tns_init(tns_t *tns, const fileinfo_t *files, const int *cnt, int *sel,
|
|
|
|
|
void tns_init(tns_t *tns, fileinfo_t *files, const int *cnt, int *sel,
|
|
|
|
|
win_t *win)
|
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
@ -169,7 +169,8 @@ void tns_init(tns_t *tns, const fileinfo_t *files, const int *cnt, int *sel,
|
|
|
|
|
}
|
|
|
|
|
tns->files = files;
|
|
|
|
|
tns->cnt = cnt;
|
|
|
|
|
tns->loadnext = tns->first = tns->end = tns->r_first = tns->r_end = 0;
|
|
|
|
|
tns->initnext = tns->loadnext = 0;
|
|
|
|
|
tns->first = tns->end = tns->r_first = tns->r_end = 0;
|
|
|
|
|
tns->sel = sel;
|
|
|
|
|
tns->win = win;
|
|
|
|
|
tns->dirty = false;
|
|
|
|
@ -237,7 +238,7 @@ Imlib_Image tns_scale_down(Imlib_Image im, int dim)
|
|
|
|
|
return im;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool tns_load(tns_t *tns, int n, bool force)
|
|
|
|
|
bool tns_load(tns_t *tns, int n, bool force, bool cache_only)
|
|
|
|
|
{
|
|
|
|
|
int w, h;
|
|
|
|
|
int maxwh = thumb_sizes[ARRLEN(thumb_sizes)-1];
|
|
|
|
@ -245,8 +246,8 @@ bool tns_load(tns_t *tns, int n, bool force)
|
|
|
|
|
char *cfile;
|
|
|
|
|
float zw, zh;
|
|
|
|
|
thumb_t *t;
|
|
|
|
|
fileinfo_t *file;
|
|
|
|
|
Imlib_Image im = NULL;
|
|
|
|
|
const fileinfo_t *file;
|
|
|
|
|
|
|
|
|
|
if (tns == NULL || tns->thumbs == NULL)
|
|
|
|
|
return false;
|
|
|
|
@ -261,6 +262,7 @@ bool tns_load(tns_t *tns, int n, bool force)
|
|
|
|
|
if (t->im != NULL) {
|
|
|
|
|
imlib_context_set_image(t->im);
|
|
|
|
|
imlib_free_image();
|
|
|
|
|
t->im = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!force) {
|
|
|
|
@ -345,10 +347,10 @@ bool tns_load(tns_t *tns, int n, bool force)
|
|
|
|
|
warn("could not open image: %s", file->name);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
imlib_context_set_image(im);
|
|
|
|
|
|
|
|
|
|
if (!cache_hit) {
|
|
|
|
|
#if HAVE_LIBEXIF
|
|
|
|
|
imlib_context_set_image(im);
|
|
|
|
|
exif_auto_orientate(file);
|
|
|
|
|
#endif
|
|
|
|
|
im = tns_scale_down(im, maxwh);
|
|
|
|
@ -357,12 +359,22 @@ bool tns_load(tns_t *tns, int n, bool force)
|
|
|
|
|
tns_cache_write(im, file->path, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t->im = tns_scale_down(im, thumb_sizes[tns->zl]);
|
|
|
|
|
imlib_context_set_image(t->im);
|
|
|
|
|
t->w = imlib_image_get_width();
|
|
|
|
|
t->h = imlib_image_get_height();
|
|
|
|
|
if (cache_only) {
|
|
|
|
|
imlib_free_image_and_decache();
|
|
|
|
|
} else {
|
|
|
|
|
t->im = tns_scale_down(im, thumb_sizes[tns->zl]);
|
|
|
|
|
imlib_context_set_image(t->im);
|
|
|
|
|
t->w = imlib_image_get_width();
|
|
|
|
|
t->h = imlib_image_get_height();
|
|
|
|
|
tns->dirty = true;
|
|
|
|
|
}
|
|
|
|
|
file->flags |= FF_TN_INIT;
|
|
|
|
|
|
|
|
|
|
if (n == tns->initnext)
|
|
|
|
|
while (++tns->initnext < *tns->cnt && ((++file)->flags & FF_TN_INIT));
|
|
|
|
|
if (n == tns->loadnext && !cache_only)
|
|
|
|
|
while (++tns->loadnext < tns->end && (++t)->im != NULL);
|
|
|
|
|
|
|
|
|
|
tns->dirty = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|