Map API refactoring
[GPXSee.git] / src / map / ozf.h
bloba7551dfde9431c7c48facc347a9daa5dde3915aa
1 #ifndef OZF_H
2 #define OZF_H
4 #include <QString>
5 #include <QSize>
6 #include <QColor>
7 #include <QList>
8 #include <QVector>
9 #include <QFile>
10 #include <QPixmap>
12 class OZF
14 public:
15 OZF(const QString &name) : _tileSize(0), _decrypt(false), _key(0),
16 _file(name) {}
18 bool open();
19 void close() {_file.close();}
21 QString fileName() const {return _file.fileName();}
22 bool isOpen() const {return _file.isOpen();}
24 int zooms() const {return _zooms.size();}
25 QSize size(int zoom) const;
26 QPointF scale(int zoom) const;
27 QSize tileSize() const {return QSize(_tileSize, _tileSize);}
28 QPixmap tile(int zoom, int x, int y);
30 static bool isOZF(const QString &path);
32 private:
33 struct Zoom {
34 QSize size;
35 QSize dim;
36 QVector<QRgb> palette;
37 QVector<quint32> tiles;
40 template<class T> bool readValue(T &val);
41 bool read(void *data, size_t size, size_t decryptSize = 0);
42 bool initOZF3();
43 bool initOZF2();
44 bool readHeaders();
45 bool readTileTable();
47 quint16 _tileSize;
48 bool _decrypt;
49 quint8 _key;
50 QList<Zoom> _zooms;
51 QFile _file;
54 #endif // OZF_H