From 75ed1596bdda336afff461853bc545d33508392d Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Tue, 29 Oct 2024 13:10:59 +0100 Subject: [PATCH] Fix MapSnapshotter icon loading (#2967) --- .gitignore | 4 ++++ .../java/org/maplibre/android/snapshotter/MapSnapshotter.kt | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5312c2ca9ea..f417555efd5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ /platform/android/MapLibreAndroidTestApp/.cxx /platform/android/MapLibreAndroidTestApp/build /platform/android/.gradle +/platform/android/buildSrc/.gradle +/platform/android/buildSrc/build /platform/android/x86 /platform/android/x86_64 /cmake-build-debug @@ -58,3 +60,5 @@ cache.sqlite-journal out.png /test/android/app/.cxx /test/android/app/build +/test/android/local.properties +/render-test/android/local.properties diff --git a/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/snapshotter/MapSnapshotter.kt b/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/snapshotter/MapSnapshotter.kt index f1e0df6cd59..8aabf4141ac 100644 --- a/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/snapshotter/MapSnapshotter.kt +++ b/platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/snapshotter/MapSnapshotter.kt @@ -12,6 +12,7 @@ import android.widget.TextView import androidx.annotation.Keep import androidx.annotation.UiThread import androidx.core.content.res.ResourcesCompat +import androidx.core.graphics.drawable.toBitmap import org.maplibre.android.R import org.maplibre.android.attribution.AttributionLayout import org.maplibre.android.attribution.AttributionMeasure @@ -568,7 +569,7 @@ open class MapSnapshotter(context: Context, options: Options) { * @return the scaled large logo */ private fun createScaledLogo(snapshot: Bitmap): Logo { - val logo = BitmapFactory.decodeResource(context.resources, R.drawable.maplibre_logo_icon, null) + val logo = context.resources.getDrawable(R.drawable.maplibre_logo_icon, null)?.toBitmap()!! val scale = calculateLogoScale(snapshot, logo) val matrix = Matrix() matrix.postScale(scale, scale)