fun Drawable.toBitmap(@Px width: Int = intrinsicWidth, @Px height: Int = intrinsicHeight, config: Config? = null): Bitmap
Return a Bitmap representation of this Drawable.
If this instance is a BitmapDrawable and the width, height, and config match, the underlying Bitmap instance will be returned directly. If any of those three properties differ then a new Bitmap is created. For all other Drawable types, a new Bitmap is created.
width
- Width of the desired bitmap. Defaults to Drawable.getIntrinsicWidth.
height
- Height of the desired bitmap. Defaults to Drawable.getIntrinsicHeight.
config
- Bitmap config of the desired bitmap. Null attempts to use the native config, if
any. Defaults to Config.ARGB_8888 otherwise.