core-ktx / androidx.graphics / android.graphics.Bitmap / scale

scale

inline fun Bitmap.scale(width: Int, height: Int, filter: Boolean = true): Bitmap

Creates a new bitmap, scaled from this bitmap, when possible. If the specified width and height are the same as the current width and height of this bitmap, this bitmap is returned and no new bitmap is created.

Parameters

width - The new bitmap's desired width

height - The new bitmap's desired height

filter - true if the source should be filtered (true by default)

Return
The new scaled bitmap or the source bitmap if no scaling is required.