1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-07 16:02:51 +02:00

Compare commits

..

18 Commits
9.8 ... 9.10

Author SHA1 Message Date
442625232c Version++ 2021-10-25 11:32:50 +02:00
6b70f4a958 Use QTextCodec for conversions to UTF on Qt5
This way we can support East Asian encodings at least on Qt5 in some way
(the Qt codecs are not 100% compatible with the CPx encodings, but the result
should be much better than a fallback to cp1250...).
2021-10-25 10:30:09 +02:00
f810117cbe Added waypoint icons highlighting 2021-10-24 14:31:31 +02:00
7fe82b12fe Code cleanup 2021-10-24 12:56:09 +02:00
94e2d58805 Updated debug stuff 2021-10-24 12:30:31 +02:00
8046d06e32 Removed obsolete include/namespace 2021-10-23 23:07:28 +02:00
532bd39bc2 Reuse the symbol table decoder in the text decoder 2021-10-23 22:53:10 +02:00
c487d9c66b Make the table pointers const 2021-10-23 17:28:06 +02:00
37dddbb18c Code cleanup 2021-10-23 13:05:06 +02:00
37a4f80fbb Cosmetics 2021-10-23 10:27:41 +02:00
a531b7859b Added basic table data sanity checks
+ some more code cleanup
2021-10-23 07:41:27 +02:00
ccfda7ca7f Code cleanup 2021-10-22 22:04:46 +02:00
8e867851e9 Various GPI symbol handling fixes 2021-10-18 23:10:09 +02:00
5e36d564aa Added workaround for antipode routes
Fixes #155
2021-10-16 14:11:22 +02:00
db4ed75757 Merge branch 'origin/master' into Weblate. 2021-10-15 19:27:45 +02:00
4eae93e403 Version++ 2021-10-15 19:27:23 +02:00
6ffeefe9c9 Fixed scroll wheel zooming on devices with "fine-resolution wheels" 2021-10-15 19:24:50 +02:00
4069bfcc6e Translated using Weblate (Finnish)
Currently translated at 98.1% (414 of 422 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/fi/
2021-10-14 22:04:18 +02:00
20 changed files with 248 additions and 258 deletions

View File

@ -1,4 +1,4 @@
version: 9.8.{build}
version: 9.10.{build}
configuration:
- Release

View File

@ -3,7 +3,7 @@ unix:!macx {
} else {
TARGET = GPXSee
}
VERSION = 9.8
VERSION = 9.10
QT += core \
gui \

View File

@ -697,7 +697,7 @@
<message>
<location filename="../src/GUI/gui.cpp" line="808"/>
<source>Symbols directory:</source>
<translation type="unfinished"></translation>
<translation>Symbolien hakemisto:</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="1180"/>

View File

@ -9,7 +9,7 @@ Unicode true
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "9.8"
!define VERSION "9.10"
; The file to write
OutFile "GPXSee-${VERSION}.exe"

View File

@ -9,7 +9,7 @@ Unicode true
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "9.8"
!define VERSION "9.10"
; The file to write
OutFile "GPXSee-${VERSION}_x64.exe"

View File

@ -350,12 +350,12 @@ void GraphView::mousePressEvent(QMouseEvent *e)
void GraphView::wheelEvent(QWheelEvent *e)
{
static int deg = 0;
static int deg8 = 0;
deg += e->angleDelta().y() / 8;
if (qAbs(deg) < 15)
deg8 += e->angleDelta().y();
if (qAbs(deg8) < (15 * 8))
return;
deg = 0;
deg8 = deg8 % (15 * 8);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QPointF pos = mapToScene(e->pos());

View File

@ -586,17 +586,17 @@ void MapView::zoom(int zoom, const QPoint &pos, bool shift)
void MapView::wheelEvent(QWheelEvent *event)
{
static int deg = 0;
static int deg8 = 0;
bool shift = (event->modifiers() & MODIFIER) ? true : false;
// Shift inverts the wheel axis on OS X, so use scrolling in both axes for
// the zoom.
int delta = event->angleDelta().y()
? event->angleDelta().y() : event->angleDelta().x();
deg += delta / 8;
if (qAbs(deg) < 15)
deg8 += delta;
if (qAbs(deg8) < (15 * 8))
return;
deg = 0;
deg8 = deg8 % (15 * 8);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
zoom((delta > 0) ? 1 : -1, event->pos(), shift);

View File

@ -104,6 +104,10 @@ void WaypointItem::updateCache()
_labelBB = fm.tightBoundingRect(_waypoint.name());
if (_showIcon && _icon) {
if (_font.bold())
p.addRect(-_icon->width() * 0.625, -_icon->height() * 1.25,
_icon->width() * 1.25, _icon->height() * 1.25);
else
p.addRect(-_icon->width()/2.0, -_icon->height(), _icon->width(),
_icon->height());
p.addRect(0, 0, _labelBB.width(), _labelBB.height() + fm.descent());
@ -113,10 +117,14 @@ void WaypointItem::updateCache()
_labelBB.height() + fm.descent());
}
} else {
if (_showIcon && _icon)
if (_showIcon && _icon) {
if (_font.bold())
p.addRect(-_icon->width() * 0.625, -_icon->height() * 1.25,
_icon->width() * 1.25, _icon->height() * 1.25);
else
p.addRect(-_icon->width()/2, -_icon->height(), _icon->width(),
_icon->height());
else
} else
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
}
@ -143,16 +151,19 @@ void WaypointItem::paint(QPainter *painter,
}
painter->setBrush(QBrush(_color, Qt::SolidPattern));
if (_showIcon && _icon)
painter->drawPixmap(-_icon->width()/2.0, -_icon->height(), *_icon);
if (_showIcon && _icon) {
if (_font.bold())
painter->drawPixmap(-_icon->width() * 0.625, -_icon->height() * 1.25,
_icon->scaled(_icon->width() * 1.25, _icon->height() * 1.25,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
else
painter->drawPixmap(-_icon->width()/2.0, -_icon->height(), *_icon);
} else
painter->drawEllipse(-pointSize/2, -pointSize/2, pointSize, pointSize);
/*
painter->setPen(Qt::red);
painter->setBrush(Qt::NoBrush);
painter->drawPath(_shape);
*/
//painter->setPen(Qt::red);
//painter->setBrush(Qt::NoBrush);
//painter->drawPath(_shape);
}
void WaypointItem::setSize(int size)

View File

@ -1,11 +1,41 @@
#include "greatcircle.h"
#define DELTA 1e-5
static bool antipodes(const Coordinates &c1, const Coordinates &c2)
{
return ((qAbs(c1.lat() + c2.lat()) < DELTA)
&& (qAbs(180.0 - qAbs(c1.lon() - c2.lon())) < DELTA));
}
GreatCircle::GreatCircle(const Coordinates &c1, const Coordinates &c2)
{
double lat1 = deg2rad(c1.lat());
double lon1 = deg2rad(c1.lon());
double lat2 = deg2rad(c2.lat());
double lon2 = deg2rad(c2.lon());
double lat1, lon1, lat2, lon2;
if (antipodes(c1, c2)) {
/* In case of antipodes (which would lead to garbage output without
this hack), move the points DELTA degrees closer to each other in
a way that the route never crosses the antimeridian. */
if (c1.lon() < c2.lon()) {
lon1 = deg2rad(c1.lon() + DELTA);
lon2 = deg2rad(c2.lon() - DELTA);
} else {
lon1 = deg2rad(c1.lon() - DELTA);
lon2 = deg2rad(c2.lon() + DELTA);
}
if (c1.lat() < c2.lat()) {
lat1 = deg2rad(c1.lat() + DELTA);
lat2 = deg2rad(c2.lat() - DELTA);
} else {
lat1 = deg2rad(c1.lat() - DELTA);
lat2 = deg2rad(c2.lat() + DELTA);
}
} else {
lat1 = deg2rad(c1.lat());
lon1 = deg2rad(c1.lon());
lat2 = deg2rad(c2.lat());
lon2 = deg2rad(c2.lon());
}
double cosLat1 = cos(lat1);
double cosLat2 = cos(lat2);

View File

@ -1,6 +1,70 @@
#include <QVector>
#include "textcodec.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QTextCodec>
TextCodec::TextCodec()
{
_codec = QTextCodec::codecForName("Windows-1252");
}
TextCodec::TextCodec(int codepage)
{
switch (codepage) {
case 65001:
_codec = 0;
break;
case 932:
_codec = QTextCodec::codecForName("Shift-JIS");
break;
case 936:
_codec = QTextCodec::codecForName("GB18030");
break;
case 949:
_codec = QTextCodec::codecForName("EUC-KR");
break;
case 950:
_codec = QTextCodec::codecForName("Big5");
break;
case 1250:
_codec = QTextCodec::codecForName("Windows-1250");
break;
case 1251:
_codec = QTextCodec::codecForName("Windows-1251");
break;
case 1253:
_codec = QTextCodec::codecForName("Windows-1253");
break;
case 1254:
_codec = QTextCodec::codecForName("Windows-1254");
break;
case 1255:
_codec = QTextCodec::codecForName("Windows-1255");
break;
case 1256:
_codec = QTextCodec::codecForName("Windows-1256");
break;
case 1257:
_codec = QTextCodec::codecForName("Windows-1257");
break;
case 1258:
_codec = QTextCodec::codecForName("Windows-1258");
break;
default:
_codec = QTextCodec::codecForName("Windows-1252");
}
}
QString TextCodec::toString(const QByteArray &ba) const
{
return _codec ? _codec->toUnicode(ba) : QString::fromUtf8(ba);
}
#else // QT6
#include <QVector>
static const char32_t cp1250[] = {
0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021,
0x0000, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
@ -192,10 +256,7 @@ TextCodec::TextCodec(int codepage)
QString TextCodec::toString(const QByteArray &ba) const
{
if (_table)
return from8bCp(ba);
else
return QString::fromUtf8(ba);
return _table ? from8bCp(ba) : QString::fromUtf8(ba);
}
QString TextCodec::from8bCp(const QByteArray &ba) const
@ -212,3 +273,4 @@ QString TextCodec::from8bCp(const QByteArray &ba) const
return QString::fromUcs4(ucs4.constData(), ucs4.size());
}
#endif // QT6

View File

@ -3,6 +3,8 @@
#include <QString>
class QTextCodec;
class TextCodec
{
public:
@ -12,9 +14,12 @@ public:
QString toString(const QByteArray &ba) const;
private:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QTextCodec *_codec;
#else // QT6
QString from8bCp(const QByteArray &ba) const;
const char32_t *_table;
#endif // QT6
};
#endif // TEXTCODEC_H

View File

@ -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;
}

View File

@ -24,7 +24,7 @@ public:
}
bool atEnd() const
{return _symbolDataSize + _bs.bitsAvailable() < _table.maxSymbolSize();}
{return _symbolDataSize + _bs.bitsAvailable() < _table.symBits();}
bool flush() {return _bs.flush();}
protected:

View File

@ -8,8 +8,8 @@ static inline quint32 readVUint32(const quint8 *buffer, quint32 bytes)
{
quint32 val = 0;
for (quint32 i = bytes; i; i--)
val |= ((quint32)*(buffer + i)) << ((i-1) * 8);
for (quint32 i = 0; i < bytes; i++)
val |= ((quint32)*(buffer + i)) << (i * 8);
return val;
}
@ -19,89 +19,83 @@ bool HuffmanTable::load(const RGNFile *rgn, SubFile::Handle &rgnHdl)
if (!_buffer.load(rgn, rgnHdl))
return false;
_s0 = (quint8)_buffer.at(0) & 0x0F;
_s1e = (quint8)_buffer.at(0) & 0x10;
_s2 = (quint8)_buffer.at(1);
_s3 = bs(_s2);
_s1d = (quint8)_buffer.at(2);
_s1f = (quint8)_buffer.at(3);
_s20 = bs(_s1f);
_s1 = _s20 + 1;
_s22 = vs(_buffer.at(4));
_s1c = _s3 + 1 + _s22;
_s14 = (quint8*)(_buffer.data()) + 4 + _s22;
_s10 = _s14 + _s1c * _s1d;
_s18 = _s10 + (_s1 << _s0);
_aclBits = (quint8)_buffer.at(0) & 0x0F;
_huffman = (quint8)_buffer.at(0) & 0x10;
_symBits = (quint8)_buffer.at(1);
_symBytes = bs(_symBits);
_bsrchEntries = (quint8)_buffer.at(2);
_symbolBits = (quint8)_buffer.at(3);
_symbolBytes = bs(_symbolBits);
_aclEntryBytes = _symbolBytes + 1;
_indexBytes = vs(_buffer.at(4));
_bsrchEntryBytes = _symBytes + _indexBytes + 1;
_bsrchTable = (const quint8*)(_buffer.constData()) + 4 + _indexBytes;
_aclTable = _bsrchTable + _bsrchEntryBytes * _bsrchEntries;
_huffmanTable = _aclTable + (_aclEntryBytes << _aclBits);
return true;
return (_symBits <= 32 && _symbolBits <= 32);
}
quint32 HuffmanTable::symbol(quint32 data, quint8 &size) const
{
quint32 ss, sym;
quint8 *tp;
quint32 lo, hi;
const quint8 *tp;
if (_s0 == 0) {
sym = _s1d - 1;
ss = 0;
if (!_aclBits) {
hi = _bsrchEntries - 1;
lo = 0;
} else {
quint32 offset = _s1 * (data >> (0x20U - _s0));
tp = _s10 + offset;
quint32 offset = _aclEntryBytes * (data >> (32 - _aclBits));
tp = _aclTable + offset;
if ((*tp & 1) != 0) {
sym = readVUint32(tp, _s20);
if (*tp & 1) {
size = *tp >> 1;
return sym;
return readVUint32(tp + 1, _symbolBytes);;
}
ss = *tp >> 1;
sym = tp[1];
lo = *tp >> 1;
hi = *(tp + 1);
}
tp = ss * _s1c + _s14;
data = data >> (0x20U - _s2);
tp = _bsrchTable + (lo * _bsrchEntryBytes);
data >>= 32 - _symBits;
quint8 *prev = tp;
while (ss < sym) {
quint32 cnt = (ss + 1 + sym) >> 1;
tp = _s14 + (cnt * _s1c);
quint32 nd = readVUint32(tp - 1, _s3);
while (lo < hi) {
const quint8 *prev = tp;
quint32 m = (lo + 1 + hi) >> 1;
tp = _bsrchTable + (m * _bsrchEntryBytes);
quint32 nd = readVUint32(tp, _symBytes);
if (data <= nd) {
if (data == nd)
ss = cnt;
else
if (data < nd) {
tp = prev;
sym = cnt - (data < nd);
cnt = ss;
hi = m - 1;
} else if (data > nd) {
lo = m;
} else {
lo = m;
hi = m;
}
ss = cnt;
prev = tp;
}
sym = readVUint32(tp - 1, _s3);
tp = tp + _s3;
ss = readVUint32(tp, _s22);
quint32 i = readVUint32(tp, _symBytes);
tp = tp + _symBytes;
size = *tp;
sym = (data - sym) >> (_s2 - *tp);
if (!_s1e)
sym = readVUint32(tp, _s20);
if (!_huffman)
return readVUint32(tp + 1, _symbolBytes);
else {
sym = (sym + ss) * _s1f;
ss = sym >> 3;
sym = sym & 7;
quint32 shift = 8 - sym;
sym = *(_s18 + ss) >> sym;
quint32 bi = readVUint32(tp + 1, _indexBytes);
quint32 ci = (data - i) >> (_symBits - size);
quint32 si = (ci + bi) * _symbolBits;
quint32 sbi = si & 7;
quint32 shift = 8 - sbi;
tp = _huffmanTable + (si >> 3);
if (shift < _s1f) {
tp = _s18 + ss;
ss = readVUint32(tp, ((_s1f + 7) - shift) >> 3);
sym = (ss << shift) | sym;
if (shift < _symbolBits) {
quint32 val = readVUint32(tp + 1, bs(_symbolBits - shift));
return (val << shift) | (*tp >> sbi);
} else
return (*tp >> sbi);
}
}
return sym;
}

View File

@ -12,18 +12,19 @@ public:
HuffmanTable(quint8 id) : _buffer(id) {}
bool load(const RGNFile *rgn, SubFile::Handle &rgnHdl);
quint8 maxSymbolSize() const {return _s2;}
quint32 symbol(quint32 data, quint8 &size) const;
quint32 symbol(quint32 data, quint8 &size) const;
quint8 id() const {return _buffer.id();}
quint8 symBits() const {return _symBits;}
quint8 symbolBits() const {return _symbolBits;}
private:
HuffmanBuffer _buffer;
quint8 _s0, _s1, _s2, _s3;
quint8 *_s10, *_s14, *_s18;
quint8 _s1c, _s1d, _s1f, _s20;
quint16 _s22;
bool _s1e;
const quint8 *_aclTable, *_bsrchTable, *_huffmanTable;
quint8 _aclBits, _aclEntryBytes, _symBits, _symBytes, _indexBytes,
_bsrchEntryBytes, _bsrchEntries, _symbolBits, _symbolBytes;
bool _huffman;
};
}

View File

@ -1,64 +1,30 @@
#include "common/garmin.h"
#include "subfile.h"
#include "huffmantext.h"
using namespace Garmin;
using namespace IMG;
static inline quint32 readVUint32(const quint8 *buffer, quint32 bytes)
{
quint32 val = 0;
for (quint32 i = 0; i < bytes; i++)
val = val | (quint32)*(buffer - i) << ((bytes - i - 1) << 3);
return val;
}
bool HuffmanText::load(const RGNFile *rgn, SubFile::Handle &rgnHdl)
{
if (!_buffer.load(rgn, rgnHdl))
return false;
quint8 *buffer = (quint8 *)_buffer.constData();
_b0 = buffer[0];
_b1 = buffer[1];
_b2 = buffer[2];
_b3 = buffer[3];
_vs = vs(buffer[4]);
_bs3 = bs(_b3);
_bs1 = bs(_b1);
_mul = _bs1 + 1 + _vs;
_bp1 = buffer + _vs + 4;
_bp2 = _bp1 + _mul * _b2;
_bp3 = _bp2 + ((_bs3 + 1) << (_b0 & 0xf));
_bp4 = _bp3 - 1;
return true;
}
bool HuffmanText::fetch(const SubFile *file, SubFile::Handle &hdl,
quint32 &data, quint32 &bits, quint32 &usedBits, quint32 &usedData) const
{
quint32 rs, ls, old;
bits = _b1 - bits;
bits = _table.symBits() - bits;
if (usedBits < bits) {
old = usedBits ? usedData >> (0x20 - usedBits) : 0;
old = usedBits ? usedData >> (32 - usedBits) : 0;
if (!file->readVUInt32SW(hdl, 4, usedData))
return false;
ls = bits - usedBits;
rs = 0x20 - (bits - usedBits);
rs = 32 - (bits - usedBits);
old = usedData >> rs | old << ls;
} else {
ls = bits;
rs = usedBits - bits;
old = usedData >> (0x20 - bits);
old = usedData >> (32 - bits);
}
usedData = usedData << ls;
data = data | old << (0x20 - _b1);
data = data | old << (32 - _table.symBits());
usedBits = rs;
return true;
@ -71,101 +37,29 @@ bool HuffmanText::decode(const SubFile *file, SubFile::Handle &hdl,
quint32 data = 0;
quint32 usedBits = 0;
quint32 usedData = 0;
quint32 ls = 8;
quint32 lo = _vs * 8 - 8;
while (true) {
if (!fetch(file, hdl, data, bits, usedBits, usedData))
return false;
quint32 off = (data >> (0x20 - (_b0 & 0xf))) * (_bs3 + 1);
quint32 sb = _bp2[off];
quint32 ss = 0;
quint32 sym = _b2 - 1;
quint32 size;
quint8 size;
quint32 sym = _table.symbol(data, size);
if ((_b0 & 0xf) == 0 || (sb & 1) == 0) {
if ((_b0 & 0xf) != 0) {
ss = sb >> 1;
sym = _bp2[off + 1];
}
quint8 *tp = _bp1 + ss * _mul;
quint32 sd = data >> (0x20 - _b1);
while (ss < sym) {
quint32 cnt = (sym + 1 + ss) >> 1;
quint8 *prev = _bp1 + cnt * _mul;
quint32 nd = readVUint32(prev + _bs1 - 1, _bs1);
if (sd <= nd) {
sym = cnt - (sd < nd);
if (sd < nd) {
prev = tp;
cnt = ss;
}
}
tp = prev;
ss = cnt;
}
quint32 o1 = readVUint32(tp + _bs1 - 1, _bs1);
tp = tp + _bs1;
quint32 o2 = readVUint32(tp + _vs, _vs);
size = tp[0];
quint32 os = (sd - o1) >> (_b1 - size);
if ((_b0 & 0x10) == 0) {
sym = readVUint32(_bp4 + (o2 + 1 + os) * _bs3, _bs3);
} else {
quint32 v = (os + o2) * _b3;
quint32 idx = v >> 3;
quint32 r = v & 7;
quint32 shift = 8 - r;
sym = _bp3[idx] >> r;
if (shift < _b3) {
quint32 sz = bs(_b3 - shift);
quint32 val = readVUint32(_bp3 + idx + sz, sz);
sym = sym | val << shift;
}
}
} else {
sym = readVUint32(_bp2 + off + _bs3, _bs3);
size = (sb >> 1);
}
if (_b1 < size)
if (_table.symBits() < size)
return false;
data = data << size;
bits = _b1 - size;
bits = _table.symBits() - size;
if ((_b3 & 7) == 0) {
for (quint32 i = 0; i < (_b3 >> 3); i++) {
if (!(_table.symbolBits() & 7)) {
for (quint32 i = 0; i < (_table.symbolBits() >> 3); i++) {
str.append((quint8)sym);
if (((quint8)sym == '\0'))
return true;
sym = sym >> 8;
}
} else {
quint32 cnt = _b3;
if (ls <= _b3) {
do {
quint32 shift = ls;
lo = sym << (8 - shift) | (quint32)((quint8)lo >> shift);
sym = sym >> shift;
str.append((uchar)lo);
if (((uchar)lo == '\0'))
return true;
cnt = cnt - ls;
ls = 8;
} while (7 < cnt);
ls = 8;
}
if (cnt != 0) {
lo = sym << (8 - cnt) | (quint32)((quint8)lo >> cnt);
ls = ls - cnt;
}
Q_ASSERT(false);
return false;
}
}
}

View File

@ -1,16 +1,17 @@
#ifndef IMG_HUFFMANTEXT_H
#define IMG_HUFFMANTEXT_H
#include "huffmanbuffer.h"
#include "huffmantable.h"
namespace IMG {
class HuffmanText
{
public:
HuffmanText() : _buffer(0) {}
HuffmanText() : _table(0) {}
bool load(const RGNFile *rgn, SubFile::Handle &rgnHdl);
bool load(const RGNFile *rgn, SubFile::Handle &rgnHdl)
{return _table.load(rgn, rgnHdl);}
bool decode(const SubFile *file, SubFile::Handle &hdl,
QVector<quint8> &str) const;
@ -18,20 +19,7 @@ private:
bool fetch(const SubFile *file, SubFile::Handle &hdl, quint32 &data,
quint32 &bits, quint32 &usedBits, quint32 &usedData) const;
HuffmanBuffer _buffer;
quint32 _b0;
quint32 _b1;
quint32 _b2;
quint32 _b3;
quint32 _vs;
quint32 _bs3;
quint32 _bs1;
quint32 _mul;
quint8 *_bp1;
quint8 *_bp2;
quint8 *_bp3;
quint8 *_bp4;
HuffmanTable _table;
};
}

View File

@ -162,10 +162,12 @@ void RasterTile::render()
drawPolygons(&painter);
drawLines(&painter);
drawTextItems(&painter, textItems);
//painter.setPen(Qt::red);
//painter.drawRect(QRect(_xy, _img.size()));
qDeleteAll(textItems);
//painter.setPen(Qt::red);
//painter.setRenderHint(QPainter::Antialiasing, false);
//painter.drawRect(QRect(_xy, _pixmap.size()));
}
void RasterTile::ll2xy(QList<MapData::Poly> &polys)

View File

@ -581,10 +581,9 @@ bool RGNFile::segments(Handle &hdl, SubDiv *subdiv, SubDiv::Segment seg[5]) cons
bool RGNFile::subdivInit(Handle &hdl, SubDiv *subdiv) const
{
SubDiv::Segment seg[5];
SubDiv::Segment extPoints, extLines, extPolygons;
SubDiv::Segment std[5], extPoints, extLines, extPolygons;
if (!segments(hdl, subdiv, seg))
if (!segments(hdl, subdiv, std))
return false;
if (subdiv->extPointsOffset() != subdiv->extPointsEnd()) {
@ -609,8 +608,8 @@ bool RGNFile::subdivInit(Handle &hdl, SubDiv *subdiv) const
extLines = SubDiv::Segment(start, end);
}
subdiv->init(seg[Point], seg[IndexedPoint], seg[Line], seg[Polygon],
seg[RoadReference], extPoints, extLines, extPolygons);
subdiv->init(std[Point], std[IndexedPoint], std[Line], std[Polygon],
std[RoadReference], extPoints, extLines, extPolygons);
return true;
}

View File

@ -2,8 +2,6 @@
#define IMG_SUBDIV_H
#include <QtGlobal>
#include "common/coordinates.h"
#include "common/garmin.h"
namespace IMG {