Code samples cleanup

This commit is contained in:
Martin Tůma 2023-12-10 17:46:39 +01:00 committed by GitHub
parent 98933deb0e
commit 3ef6c55d20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,7 +23,7 @@ QPixmap::loadFromData() functions. The zoom number is passed as ASCII string
to the functions: to the functions:
```cpp ```cpp
QPixmap pm; QPixmap pm;
pm.loadFromData(tileData, QByteArray::number(zoom)); pm.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)
@ -33,9 +33,10 @@ conversion utility.
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;
QImageReader reader(file, QByteArray::number(zoom)); QImageReader reader(file, QByteArray::number(zoom));
reader.setScaledSize(QSize(1024, 1024)); reader.setScaledSize(QSize(1024, 1024));
reader.read(&image); reader.read(&img);
``` ```
you will get 1024x1024px tiles with a pixel ratio of 2 (= HiDPI tiles). you will get 1024x1024px tiles with a pixel ratio of 2 (= HiDPI tiles).
@ -44,8 +45,8 @@ Since version 2.7 tile overzoom is supported. If you set *format* to
`$zoom;$overzoom`: `$zoom;$overzoom`:
```cpp ```cpp
QPixmap pm; QPixmap pm;
pm.loadFromData(tileData, QByteArray::number(zoom) + ';' + QByteArray fmt(QByteArray::number(zoom) + ';' + QByteArray::number(overzoom));
QByteArray::number(overzoom)); pm.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