12 Commits

4 changed files with 74 additions and 11 deletions

View File

@ -26,7 +26,7 @@ build_script:
nmake release nmake release
artifacts: artifacts:
- path: release\pbf2.dll - path: release\pbf3.dll
cache: cache:
- C:\tools\vcpkg\installed\ - C:\tools\vcpkg\installed\

54
.github/workflows/android.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Android
on:
push:
branches:
- master
jobs:
build:
name: QtPBFImagePlugin
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install protobuf compiler
run: |
sudo apt-get update
sudo apt-get install protobuf-compiler
- name: set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Run sdkmanager update
run: ${ANDROID_HOME}/tools/bin/sdkmanager --update
- name: Install android platform, platform-tools, build-tools and ndk
run: ${ANDROID_HOME}/tools/bin/sdkmanager --install "cmdline-tools;latest" "platform-tools" "platforms;android-33" "build-tools;33.0.0" "ndk;23.1.7779620"
- name: Setup NDK path
run: echo "ANDROID_NDK_ROOT=${ANDROID_HOME}/ndk/23.1.7779620/" >> $GITHUB_ENV
- name: Install Qt (Desktop)
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: '6.4.0'
- name: Install Qt (Android)
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: '6.4.0'
target: 'android'
arch: 'android_arm64_v8a'
- name: Install Android Google Protocol Buffers
run: git clone https://github.com/tumic0/android_protobuf.git
- name: Configure build
run: qmake pbfplugin.pro PROTOBUF=android_protobuf
- name: Build project
run: make -j2
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: libplugins_imageformats_libpbf_arm64-v8a.so
path: plugins/libpbf/libplugins_imageformats_libpbf_arm64-v8a.so

View File

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

View File

@ -39,9 +39,12 @@ RESOURCES += pbfplugin.qrc
DEFINES += QT_NO_DEPRECATED_WARNINGS DEFINES += QT_NO_DEPRECATED_WARNINGS
unix:!macx{ unix:!macx:!android {
LIBS += -lprotobuf-lite \ LIBS += -lprotobuf-lite \
-lz -lz
target.path += $$[QT_INSTALL_PLUGINS]/imageformats
INSTALLS += target
} }
win32 { win32 {
INCLUDEPATH += $$PROTOBUF/include \ INCLUDEPATH += $$PROTOBUF/include \
@ -58,6 +61,12 @@ macx {
LIBS += $$PROTOBUF/lib/libprotobuf-lite.a \ LIBS += $$PROTOBUF/lib/libprotobuf-lite.a \
-lz -lz
} }
android {
INCLUDEPATH += $$PROTOBUF/include
LIBS += $$PROTOBUF/$$ANDROID_TARGET_ARCH/libprotobuf-lite.a \
-lz
target.path += $$[QT_INSTALL_PLUGINS]/imageformats top_builddir=$$shadowed($$PWD)
INSTALLS += target DESTDIR = $$top_builddir/plugins/libpbf
TARGET = $$qt5LibraryTarget(libpbf, "plugins/imageformats/")
}