Fix MapSnapshotter icon loading (#2967)

This commit is contained in:
Ilya Zverev
2024-10-29 13:10:59 +01:00
committed by GitHub
parent e95e0e1e63
commit 75ed1596bd
2 changed files with 6 additions and 1 deletions

4
.gitignore vendored
View File

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

View File

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