1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 19:55:53 +01:00

Added missing pixmap caching

This commit is contained in:
Martin Tůma 2018-05-30 22:10:35 +02:00
parent 2c816a509b
commit ca7016176f

View File

@ -1,6 +1,7 @@
#include <QtEndian> #include <QtEndian>
#include <QPainter> #include <QPainter>
#include <QFileInfo> #include <QFileInfo>
#include <QPixmapCache>
#include "transform.h" #include "transform.h"
#include "rectd.h" #include "rectd.h"
#include "jnxmap.h" #include "jnxmap.h"
@ -212,6 +213,10 @@ int JNXMap::zoomOut()
QPixmap JNXMap::pixmap(const Tile *tile, QFile *file) QPixmap JNXMap::pixmap(const Tile *tile, QFile *file)
{ {
QPixmap pm;
QString key = file->fileName() + "-" + QString::number(tile->offset);
if (!QPixmapCache::find(key, &pm)) {
QByteArray ba; QByteArray ba;
ba.resize(tile->size + 2); ba.resize(tile->size + 2);
ba[0] = (char)0xFF; ba[0] = (char)0xFF;
@ -222,8 +227,13 @@ QPixmap JNXMap::pixmap(const Tile *tile, QFile *file)
return QPixmap(); return QPixmap();
if (!file->read(data, tile->size)) if (!file->read(data, tile->size))
return QPixmap(); return QPixmap();
pm = QPixmap::fromImage(QImage::fromData(ba));
return QPixmap::fromImage(QImage::fromData(ba)); if (!pm.isNull())
QPixmapCache::insert(key, pm);
}
return pm;
} }
bool JNXMap::cb(Tile *tile, void *context) bool JNXMap::cb(Tile *tile, void *context)