ensureBitmapRead

fun ensureBitmapRead(file: File, size: Pair<Int, Int>? = null, scale: Int? = null): Bitmap

Reads the contents of a file and converts them into a Bitmap. If there's a failure while decoding the file, a RuntimeException will be thrown.

Author

Arnau Mora

Since

20220104

Return

The read Bitmap.

See also

This is a non-null version of that function.

Parameters

file

The file to read the Bitmap from.

size

The size of the container where the image will be loaded at. This can be null, and the whole image will be loaded, but it's recommended to select a size, so no memory is wasted.

scale

The scale to load the image at. This will optimize memory usage, and make the device be not that much stressed.

Throws

If the Bitmap could not be read.