core-ktx / androidx.graphics / createBitmap

createBitmap

inline fun createBitmap(width: Int, height: Int, config: Config = Bitmap.Config.ARGB_8888): Bitmap

Returns a mutable bitmap with the specified width and height. A config can be optionally specified. If not, the default config is Bitmap.Config.ARGB_8888.

Parameters

width - The new bitmap's desired width

height - The new bitmap's desired height

config - The new bitmap's desired config

Return
A new bitmap with the specified dimensions and config

inline fun createBitmap(width: Int, height: Int, config: Config = Bitmap.Config.ARGB_8888, hasAlpha: Boolean = true, colorSpace: ColorSpace = ColorSpace.get(ColorSpace.Named.SRGB)): Bitmap

Returns a mutable bitmap with the specified width and height. The config, transparency and color space can optionally be specified. They respectively default to Bitmap.Config.ARGB_8888, true and sRGB.

Parameters

width - The new bitmap's desired width

height - The new bitmap's desired height

config - The new bitmap's desired config

hasAlpha - Whether the new bitmap is opaque or not

colorSpace - The new bitmap's color space

Return
A new bitmap with the specified dimensions and config