toBitmapOrNull
Returns a Bitmap representation of this Drawable or null
if the drawable cannot be represented as a bitmap.
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.
If the result of BitmapDrawable.getBitmap is null
or the drawable cannot otherwise be represented as a bitmap, returns null
.
Parameters
Width of the desired bitmap. Defaults to Drawable.getIntrinsicWidth.
Height of the desired bitmap. Defaults to Drawable.getIntrinsicHeight.
Bitmap config of the desired bitmap. Null attempts to use the native config, if any. Defaults to Config.ARGB_8888 otherwise.