@@ -77,7 +77,10 @@ class MapMarkerBuilder(
7777 val height = (svg.documentHeight.takeIf { it > 0 } ? : 128f ).toInt()
7878
7979 createBitmap(width, height).apply {
80- Canvas (this ).also (svg::renderToCanvas)
80+ density = context.resources.displayMetrics.densityDpi
81+ Canvas (this ).also {
82+ svg.renderToCanvas(it)
83+ }
8184 }
8285 }
8386
@@ -98,10 +101,12 @@ class MapMarkerBuilder(
98101 val innerSvg = SVG .getFromString(svgText)
99102 val w = innerSvg.documentWidth.takeIf { it > 0 } ? : 128f
100103 val h = innerSvg.documentHeight.takeIf { it > 0 } ? : 128f
101- val bmp = createBitmap(w.toInt(), h.toInt())
102- val canvas = Canvas (bmp)
103- innerSvg.renderToCanvas(canvas)
104- bmp
104+ createBitmap(w.toInt(), h.toInt()).apply {
105+ density = context.resources.displayMetrics.densityDpi
106+ Canvas (this ).also {
107+ innerSvg.renderToCanvas(it)
108+ }
109+ }
105110 } else {
106111 conn.inputStream.use { BitmapFactory .decodeStream(it) }
107112 }
@@ -328,27 +333,28 @@ class MapMarkerBuilder(
328333 coroutineContext.ensureActive()
329334 val svg = SVG .getFromString(m.iconSvg.svgString)
330335
331- coroutineContext.ensureActive()
332- svg.setDocumentWidth(m.iconSvg.width.dpToPx())
333- svg.setDocumentHeight(m.iconSvg.height.dpToPx())
336+ val wPx =
337+ m.iconSvg.width
338+ .dpToPx()
339+ .toInt()
340+ val hPx =
341+ m.iconSvg.height
342+ .dpToPx()
343+ .toInt()
334344
335345 coroutineContext.ensureActive()
336- bmp =
337- createBitmap(
338- m.iconSvg.width
339- .dpToPx()
340- .toInt(),
341- m.iconSvg.height
342- .dpToPx()
343- .toInt(),
344- Bitmap .Config .ARGB_8888 ,
345- )
346+ svg.setDocumentWidth(wPx.toFloat())
347+ svg.setDocumentHeight(hPx.toFloat())
346348
347349 coroutineContext.ensureActive()
348- val canvas = Canvas (bmp)
349- svg.renderToCanvas(canvas)
350+ bmp =
351+ createBitmap(wPx, hPx, Bitmap .Config .ARGB_8888 ).apply {
352+ density = context.resources.displayMetrics.densityDpi
353+ Canvas (this ).also {
354+ svg.renderToCanvas(it)
355+ }
356+ }
350357
351- coroutineContext.ensureActive()
352358 return bmp
353359 } catch (t: Throwable ) {
354360 try {
0 commit comments