Store Thumbnails with image hashes
This drastically improves the time it takes to select a dive with several pictures at the expense of longer startup and bigger hash files. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
committed by
Dirk Hohndel
parent
e0f43d8a84
commit
2075038de1
@@ -6,19 +6,21 @@
|
||||
|
||||
#include <QtConcurrent>
|
||||
|
||||
extern QHash <QString, QImage > thumbnailCache;
|
||||
|
||||
|
||||
SPixmap scaleImages(picturepointer picture)
|
||||
{
|
||||
static QHash <QString, QImage > cache;
|
||||
SPixmap ret;
|
||||
ret.first = picture;
|
||||
if (cache.contains(picture->filename) && !cache.value(picture->filename).isNull()) {
|
||||
ret.second = cache.value(picture->filename);
|
||||
if (thumbnailCache.contains(picture->filename) && !thumbnailCache.value(picture->filename).isNull()) {
|
||||
ret.second = thumbnailCache.value(picture->filename);
|
||||
} else {
|
||||
int dim = defaultIconMetrics().sz_pic;
|
||||
QImage p = SHashedImage(picture);
|
||||
if(!p.isNull()) {
|
||||
p = p.scaled(dim, dim, Qt::KeepAspectRatio);
|
||||
cache.insert(picture->filename, p);
|
||||
thumbnailCache.insert(picture->filename, p);
|
||||
}
|
||||
ret.second = p;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user