fromResource

fun fromResource(context: Context, @DrawableRes resId: Int, anchor: Point? = null, scaledSize: Size? = null): Icon

Build an Icon from a drawable resource.

Handles both bitmap-backed drawables (PNG/JPG via BitmapFactory.decodeResource) and <vector> drawables (rasterised via Drawable.draw at xxhdpi density when scaledSize is null).

val icon = Icon.fromResource(context, R.drawable.my_pin)

Throws

if the resource cannot be resolved or decoded.