calculateInSampleSize

fun calculateInSampleSize(options: BitmapFactory.Options, destinationWidth: Int, destinationHeight: Int): Int

Gets the sample factor given a bitmap's dimensions and destination view's bounds.

Taken from https://developer.android.com/topic/performance/graphics/load-bitmap.html

Return

The sample factor. Will be a power of 2.

Parameters

options

The metadata for the bitmap. This should contain the android.graphics.BitmapFactory.Options.outHeight and android.graphics.BitmapFactory.Options.outWidth fields set.

destinationWidth

The width of the destination view in pixels.

destinationHeight

The height of the destination view in pixels.