mirror of
https://github.com/tumic0/QtPBFImagePlugin.git
synced 2024-11-24 03:35:54 +01:00
Unify the code samples to use QImage
This commit is contained in:
parent
f5f006dc7b
commit
d8a521623a
14
README.md
14
README.md
@ -18,19 +18,19 @@ to fit the styles and available data (OpenMapTiles, Mapbox tiles).
|
|||||||
Due to a major design flaw in the Mapbox vector tiles specification - the zoom
|
Due to a major design flaw in the Mapbox vector tiles specification - the zoom
|
||||||
is not part of the PBF data - the plugin can not be used "as is", but passing
|
is not part of the PBF data - the plugin can not be used "as is", but passing
|
||||||
the zoom level is necessary. This is done by exploiting the optional *format*
|
the zoom level is necessary. This is done by exploiting the optional *format*
|
||||||
parameter of the QImage constructor or the QImage::fromData() or
|
parameter of the QImage constructor or the *QImage::loadFromData()* or
|
||||||
QPixmap::loadFromData() functions. The zoom number is passed as ASCII string
|
*QPixmap::loadFromData()* functions. The zoom number is passed as ASCII string
|
||||||
to the functions:
|
to the functions:
|
||||||
```cpp
|
```cpp
|
||||||
QPixmap pm;
|
QImage img;
|
||||||
pm.loadFromData(data, QByteArray::number(zoom));
|
img.loadFromData(data, QByteArray::number(zoom));
|
||||||
```
|
```
|
||||||
|
|
||||||
For a complete code sample see the [pbf2png](https://github.com/tumic0/pbf2png)
|
For a complete code sample see the [pbf2png](https://github.com/tumic0/pbf2png)
|
||||||
conversion utility.
|
conversion utility.
|
||||||
|
|
||||||
### HiDPI
|
### HiDPI
|
||||||
The plugin supports vector scaling using QImageReader's setScaledSize() method,
|
The plugin supports vector scaling using QImageReader's *setScaledSize()* method,
|
||||||
so when used like in the following example:
|
so when used like in the following example:
|
||||||
```cpp
|
```cpp
|
||||||
QImage img;
|
QImage img;
|
||||||
@ -44,9 +44,9 @@ you will get 1024x1024px tiles with a pixel ratio of 2 (= HiDPI tiles).
|
|||||||
Since version 3 of the plugin tile overzoom is supported. If you set *format*
|
Since version 3 of the plugin tile overzoom is supported. If you set *format*
|
||||||
to `$zoom;$overzoom`:
|
to `$zoom;$overzoom`:
|
||||||
```cpp
|
```cpp
|
||||||
QPixmap pm;
|
QImage img;
|
||||||
QByteArray fmt(QByteArray::number(zoom) + ';' + QByteArray::number(overzoom));
|
QByteArray fmt(QByteArray::number(zoom) + ';' + QByteArray::number(overzoom));
|
||||||
pm.loadFromData(data, fmt);
|
img.loadFromData(data, fmt);
|
||||||
```
|
```
|
||||||
you will get (512<<overzoom)x(512<<overzoom)px tiles with a pixel ratio of 1.
|
you will get (512<<overzoom)x(512<<overzoom)px tiles with a pixel ratio of 1.
|
||||||
When overzoom is combined with setScaledSize(), the base size is the overzoomed
|
When overzoom is combined with setScaledSize(), the base size is the overzoomed
|
||||||
|
Loading…
Reference in New Issue
Block a user