1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 14:53:21 +02:00

Optimization

This commit is contained in:
Martin Tůma 2017-08-09 11:32:05 +02:00
parent 359a9f0a5a
commit e792bf3b23

View File

@ -215,13 +215,15 @@ QPixmap OZF::tile(int x, int y)
if (!_file.seek(_tiles.at(i))) if (!_file.seek(_tiles.at(i)))
return QPixmap(); return QPixmap();
QByteArray ba = _file.read(size); quint32 bes = qToBigEndian(tileSize().width() * tileSize().height());
if (ba.size() != size) QByteArray ba;
ba.resize(sizeof(bes) + size);
*(ba.data()) = bes;
if (_file.read(ba.data() + sizeof(bes), size) != size)
return QPixmap(); return QPixmap();
if (_decrypt) if (_decrypt)
decrypt(ba.data(), qMin(16, ba.size()), _key); decrypt(ba.data() + sizeof(bes), qMin(16, size), _key);
quint32 bes = qToBigEndian(tileSize().width() * tileSize().height());
ba.prepend(QByteArray((char*)&bes, sizeof(bes)));
QByteArray uba = qUncompress(ba); QByteArray uba = qUncompress(ba);
if (uba.size() != tileSize().width() * tileSize().height()) if (uba.size() != tileSize().width() * tileSize().height())
return QPixmap(); return QPixmap();