DrawableKt
public final class DrawableKt
Summary
Public methods |
|
|---|---|
static final @NonNull Bitmap |
|
static final Bitmap |
toBitmapOrNull(Returns a |
static final void |
Updates this drawable's bounds. |
Public methods
toBitmap
public static final @NonNull Bitmap toBitmap(
@NonNull Drawable receiver,
@Px int width,
@Px int height,
Bitmap.Config config
)
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.
| Parameters | |
|---|---|
@Px int width |
Width of the desired bitmap. Defaults to |
@Px int height |
Height of the desired bitmap. Defaults to |
Bitmap.Config config |
Bitmap config of the desired bitmap. Null attempts to use the native config, if any. Defaults to |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the underlying drawable is a |
| See also | |
|---|---|
toBitmapOrNull |
toBitmapOrNull
public static final Bitmap toBitmapOrNull(
@NonNull Drawable receiver,
@Px int width,
@Px int height,
Bitmap.Config config
)
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 | |
|---|---|
@Px int width |
Width of the desired bitmap. Defaults to |
@Px int height |
Height of the desired bitmap. Defaults to |
Bitmap.Config config |
Bitmap config of the desired bitmap. Null attempts to use the native config, if any. Defaults to |
| See also | |
|---|---|
toBitmap |