mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-30 22:51:16 +01:00
Compare commits
3 Commits
5f3203d638
...
a0ce50e7e4
Author | SHA1 | Date | |
---|---|---|---|
a0ce50e7e4 | |||
031d82f689 | |||
99f620f101 |
@ -41,6 +41,7 @@ static bool isAllUpperCase(const QString &str)
|
||||
|
||||
for (int i = 0; i < str.size(); i++) {
|
||||
QChar c(str.at(i));
|
||||
|
||||
if (c.isLetter() && !(c.isUpper() || c == QChar(0x00DF)))
|
||||
return false;
|
||||
}
|
||||
@ -54,14 +55,14 @@ static QString capitalized(const QString &str)
|
||||
|
||||
ret.resize(str.size());
|
||||
|
||||
for (int i = 0; i < str.size(); i++) {
|
||||
QChar last(str.at(i-1));
|
||||
QChar current(str.at(i));
|
||||
if (!str.isEmpty())
|
||||
ret[0] = str.at(0);
|
||||
|
||||
if (i && !(last.isSpace() || last == '('))
|
||||
ret[i] = current.toLower();
|
||||
else
|
||||
ret[i] = current;
|
||||
for (int i = 1; i < str.size(); i++) {
|
||||
QChar last(str.at(i-1));
|
||||
QChar c(str.at(i));
|
||||
|
||||
ret[i] = (last.isSpace() || last == '(') ? c : c.toLower();
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -77,8 +78,6 @@ static QByteArray ft2m(const QByteArray &str)
|
||||
LBLFile::~LBLFile()
|
||||
{
|
||||
delete _huffmanText;
|
||||
delete[] _table;
|
||||
delete[] _rasters;
|
||||
}
|
||||
|
||||
bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
|
||||
@ -102,10 +101,10 @@ bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
|
||||
return false;
|
||||
|
||||
if (size && recordSize) {
|
||||
_table = new quint32[size / recordSize];
|
||||
_table.resize(size / recordSize);
|
||||
if (!seek(hdl, offset))
|
||||
return false;
|
||||
for (quint32 i = 0; i < size / recordSize; i++) {
|
||||
for (quint32 i = 0; i < _table.size(); i++) {
|
||||
if (!readVUInt32(hdl, recordSize, _table[i]))
|
||||
return false;
|
||||
}
|
||||
@ -138,12 +137,10 @@ bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
|
||||
|
||||
void LBLFile::clear()
|
||||
{
|
||||
_table = QVector<quint32>();
|
||||
_rasters = QVector<Image>();
|
||||
delete _huffmanText;
|
||||
delete[] _table;
|
||||
delete[] _rasters;
|
||||
_huffmanText = 0;
|
||||
_table = 0;
|
||||
_rasters = 0;
|
||||
}
|
||||
|
||||
Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
|
||||
@ -279,13 +276,15 @@ Label LBLFile::labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
|
||||
|
||||
if (!_huffmanText->decode(file, fileHdl, size, str))
|
||||
return Label();
|
||||
if (!_table)
|
||||
if (!_table.size())
|
||||
return str2label(str, capitalize, convert);
|
||||
|
||||
|
||||
QVector<quint8> str2;
|
||||
for (int i = 0; i < str.size(); i++) {
|
||||
quint32 val = _table[str.at(i)];
|
||||
quint8 c(str.at(i));
|
||||
quint32 val = (c < _table.size()) ? _table.at(c) : 0;
|
||||
|
||||
if (val) {
|
||||
quint32 off = _base.offset + ((val & 0x7fffff) << _shift);
|
||||
if (!seek(hdl, off))
|
||||
@ -300,13 +299,13 @@ Label LBLFile::labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
|
||||
str2))
|
||||
return Label();
|
||||
} else {
|
||||
if (str.at(i) == 7) {
|
||||
if (c == 7) {
|
||||
str2.append(0);
|
||||
break;
|
||||
}
|
||||
if (str2.size() && str2.back() == '\0')
|
||||
str2[str2.size() - 1] = ' ';
|
||||
str2.append(str.at(i));
|
||||
str2.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,15 +355,15 @@ bool LBLFile::loadRasterTable(Handle &hdl, quint32 offset, quint32 size,
|
||||
quint32 recordSize)
|
||||
{
|
||||
quint32 prev, cur;
|
||||
quint32 imgCount = size / recordSize;
|
||||
|
||||
_imgCount = size / recordSize;
|
||||
_imgIdSize = byteSize(_imgCount - 1);
|
||||
_rasters = new Image[_imgCount];
|
||||
_imgIdSize = byteSize(imgCount - 1);
|
||||
_rasters.resize(imgCount);
|
||||
|
||||
if (!(seek(hdl, offset) && readVUInt32(hdl, recordSize, prev)))
|
||||
return false;
|
||||
|
||||
for (quint32 i = 1; i < _imgCount; i++) {
|
||||
for (quint32 i = 1; i < imgCount; i++) {
|
||||
if (!readVUInt32(hdl, recordSize, cur))
|
||||
return false;
|
||||
|
||||
@ -374,8 +373,8 @@ bool LBLFile::loadRasterTable(Handle &hdl, quint32 offset, quint32 size,
|
||||
prev = cur;
|
||||
}
|
||||
|
||||
_rasters[_imgCount-1].offset = prev;
|
||||
_rasters[_imgCount-1].size = _img.size - prev;
|
||||
_rasters[imgCount-1].offset = prev;
|
||||
_rasters[imgCount-1].size = _img.size - prev;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -384,14 +383,14 @@ QPixmap LBLFile::image(Handle &hdl, quint32 id) const
|
||||
{
|
||||
QPixmap pm;
|
||||
|
||||
if (id >= _imgCount)
|
||||
if (id >= _rasters.size())
|
||||
return pm;
|
||||
|
||||
if (!seek(hdl, _img.offset + _rasters[id].offset))
|
||||
if (!seek(hdl, _img.offset + _rasters.at(id).offset))
|
||||
return pm;
|
||||
QByteArray ba;
|
||||
ba.resize(_rasters[id].size);
|
||||
if (!read(hdl, ba.data(), _rasters[id].size))
|
||||
ba.resize(_rasters.at(id).size);
|
||||
if (!read(hdl, ba.data(), ba.size()))
|
||||
return pm;
|
||||
|
||||
pm.loadFromData(ba, "jpeg");
|
||||
|
@ -16,14 +16,14 @@ class LBLFile : public SubFile
|
||||
{
|
||||
public:
|
||||
LBLFile(const IMGData *img)
|
||||
: SubFile(img), _huffmanText(0), _table(0), _rasters(0), _imgIdSize(0),
|
||||
_poiShift(0), _shift(0), _encoding(0) {}
|
||||
: SubFile(img), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0),
|
||||
_encoding(0) {}
|
||||
LBLFile(const QString *path)
|
||||
: SubFile(path), _huffmanText(0), _table(0), _rasters(0), _imgIdSize(0),
|
||||
_poiShift(0), _shift(0), _encoding(0) {}
|
||||
: SubFile(path), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0),
|
||||
_encoding(0) {}
|
||||
LBLFile(const SubFile *gmp, quint32 offset)
|
||||
: SubFile(gmp, offset), _huffmanText(0), _table(0), _rasters(0),
|
||||
_imgIdSize(0), _poiShift(0), _shift(0), _encoding(0) {}
|
||||
: SubFile(gmp, offset), _huffmanText(0), _imgIdSize(0), _poiShift(0),
|
||||
_shift(0), _encoding(0) {}
|
||||
~LBLFile();
|
||||
|
||||
bool load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl);
|
||||
@ -55,11 +55,10 @@ private:
|
||||
quint32 recordSize);
|
||||
|
||||
HuffmanText *_huffmanText;
|
||||
quint32 *_table;
|
||||
Image *_rasters;
|
||||
QVector<Image> _rasters;
|
||||
QVector<quint32> _table;
|
||||
TextCodec _codec;
|
||||
Section _base, _poi, _img;
|
||||
quint32 _imgCount;
|
||||
quint8 _imgIdSize;
|
||||
quint8 _poiShift;
|
||||
quint8 _shift;
|
||||
|
Loading…
Reference in New Issue
Block a user