1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

Provide the zoom level to QImageReader when fetching the tile size

Although technically not needed here, it workarounds the issue with the broken
Qt SVG imageformat plugin (QTBUG-119910).
This commit is contained in:
Martin Tůma 2023-12-10 08:46:26 +01:00
parent eee4f31369
commit 63d3558b14
2 changed files with 6 additions and 9 deletions

View File

@ -129,15 +129,14 @@ bool MBTilesMap::getBounds()
bool MBTilesMap::getTileSize()
{
QString sql("SELECT tile_data FROM tiles LIMIT 1");
QString sql("SELECT zoom_level, tile_data FROM tiles LIMIT 1");
QSqlQuery query(sql, _db);
query.first();
QByteArray data = query.value(0).toByteArray();
QByteArray z(QByteArray::number(query.value(0).toInt()));
QByteArray data = query.value(1).toByteArray();
QBuffer buffer(&data);
/* Explicitly specify the image plugin in case of vector tiles
(QTBUG-119910 workaround) */
QImageReader reader(&buffer, _scalable ? QByteArray("mvt") : QByteArray());
QImageReader reader(&buffer, z);
QSize tileSize(reader.size());
if (!tileSize.isValid() || tileSize.width() != tileSize.height()) {
@ -217,9 +216,9 @@ MBTilesMap::MBTilesMap(const QString &fileName, QObject *parent)
return;
if (!getBounds())
return;
getTileFormat();
if (!getTileSize())
return;
getTileFormat();
getTilePixelRatio();
getName();

View File

@ -21,10 +21,8 @@ public:
const QPixmap &pixmap() const {return _pixmap;}
void load() {
QByteArray z(QString::number(_zoom).toLatin1());
QBuffer buffer(&_data);
QImageReader reader(&buffer, z);
QImageReader reader(&buffer, QByteArray::number(_zoom));
if (_scaledSize)
reader.setScaledSize(QSize(_scaledSize, _scaledSize));
_pixmap = QPixmap::fromImage(reader.read());