mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Yet another error handling fix.
This commit is contained in:
parent
c2a30738cb
commit
dfb69b2755
@ -305,7 +305,7 @@ bool OfflineMap::getImageInfo(const QString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_imgPath.endsWith("ozf2")) {
|
if (_imgPath.endsWith("ozf2")) {
|
||||||
if (_ozf.load(_imgPath))
|
_ozf.load(_imgPath);
|
||||||
_size = _ozf.size();
|
_size = _ozf.size();
|
||||||
} else {
|
} else {
|
||||||
QImageReader img(_imgPath);
|
QImageReader img(_imgPath);
|
||||||
|
15
src/ozf.cpp
15
src/ozf.cpp
@ -26,17 +26,12 @@ bool OZF::readHeaders()
|
|||||||
quint16 magic;
|
quint16 magic;
|
||||||
quint32 separator;
|
quint32 separator;
|
||||||
|
|
||||||
if (!readValue(magic) || magic != OZF2_MAGIC) {
|
if (!readValue(magic) || magic != OZF2_MAGIC)
|
||||||
qWarning("%s: not a OZF2 file", qPrintable(_file.fileName()));
|
|
||||||
_file.close();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!_file.seek(_file.pos() + 52))
|
if (!_file.seek(_file.pos() + 52))
|
||||||
return false;
|
return false;
|
||||||
if (!readValue(separator))
|
if (!readValue(separator) || separator != OZF2_SEPARATOR)
|
||||||
return false;
|
|
||||||
if (separator != OZF2_SEPARATOR)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -81,9 +76,8 @@ bool OZF::readTileTable()
|
|||||||
quint32 b = (bgr0 & 0x000000FF);
|
quint32 b = (bgr0 & 0x000000FF);
|
||||||
quint32 g = (bgr0 & 0x0000FF00) >> 8;
|
quint32 g = (bgr0 & 0x0000FF00) >> 8;
|
||||||
quint32 r = (bgr0 & 0x00FF0000) >> 16;
|
quint32 r = (bgr0 & 0x00FF0000) >> 16;
|
||||||
quint32 argb = 0xFF000000 | r << 16 | g << 8 | b;
|
|
||||||
|
|
||||||
_palette[i] = argb;
|
_palette[i] = 0xFF000000 | r << 16 | g << 8 | b;
|
||||||
}
|
}
|
||||||
|
|
||||||
_tiles = QVector<quint32>(_dim.width() * _dim.height() + 1);
|
_tiles = QVector<quint32>(_dim.width() * _dim.height() + 1);
|
||||||
@ -101,12 +95,15 @@ bool OZF::load(const QString &path)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!readHeaders()) {
|
if (!readHeaders()) {
|
||||||
|
qWarning("%s: not a OZF2 file", qPrintable(_file.fileName()));
|
||||||
_file.close();
|
_file.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!readTileTable()) {
|
if (!readTileTable()) {
|
||||||
|
qWarning("%s: file format error", qPrintable(_file.fileName()));
|
||||||
_file.close();
|
_file.close();
|
||||||
|
_size = QSize();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user