mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-30 22:51:16 +01:00
Various GPI symbol handling fixes
This commit is contained in:
parent
5e36d564aa
commit
8e867851e9
@ -537,7 +537,7 @@ static quint32 readPOI(DataStream &stream, QVector<Waypoint> &waypoints,
|
||||
quint8 rs;
|
||||
quint32 ds;
|
||||
qint32 lat, lon;
|
||||
quint16 s3, id;
|
||||
quint16 s3, iconId = 0;
|
||||
QList<TranslatedString> obj;
|
||||
|
||||
rs = stream.readRecordHeader(rh);
|
||||
@ -553,8 +553,7 @@ static quint32 readPOI(DataStream &stream, QVector<Waypoint> &waypoints,
|
||||
while (stream.status() == QDataStream::Ok && ds < rh.size) {
|
||||
switch (stream.nextHeaderType()) {
|
||||
case 4:
|
||||
ds += readIconId(stream, id);
|
||||
icons.append(QPair<int, quint16>(waypoints.size() - 1, id));
|
||||
ds += readIconId(stream, iconId);
|
||||
break;
|
||||
case 10:
|
||||
ds += readDescription(stream, waypoints.last());
|
||||
@ -576,6 +575,8 @@ static quint32 readPOI(DataStream &stream, QVector<Waypoint> &waypoints,
|
||||
}
|
||||
}
|
||||
|
||||
icons.append(QPair<int, quint16>(waypoints.size() - 1, iconId));
|
||||
|
||||
if (ds != rh.size)
|
||||
stream.setStatus(QDataStream::ReadCorruptData);
|
||||
|
||||
@ -659,11 +660,16 @@ static quint32 readSymbol(DataStream &stream, QPixmap &pixmap)
|
||||
img.setColorTable(palette);
|
||||
} else
|
||||
img = QImage((uchar*)data.data(), width, height, lineSize,
|
||||
QImage::Format_RGB32);
|
||||
QImage::Format_RGBX8888).rgbSwapped();
|
||||
pixmap = QPixmap::fromImage(img);
|
||||
|
||||
if (ds != rh.size)
|
||||
/* There should be no more data left in the record, but broken GPI files
|
||||
generated by pinns.co.uk tools exist in the wild so we read out
|
||||
the record as a workaround for such files. */
|
||||
if (ds > rh.size)
|
||||
stream.setStatus(QDataStream::ReadCorruptData);
|
||||
else if (ds < rh.size)
|
||||
stream.skipRawData(rh.size - ds);
|
||||
|
||||
return rs + rh.size;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user