DecodeUtils

A collection of useful utility methods for decoding images.

Functions

Link copied to clipboard
fun calculateInSampleSize(srcWidth: Int, srcHeight: Int, dstWidth: Int, dstHeight: Int, scale: Scale): Int

Calculate the BitmapFactory.Options.inSampleSize given the source dimensions of the image (srcWidth and srcHeight), the output dimensions (dstWidth, dstHeight), and the scale.

Link copied to clipboard
fun computeSizeMultiplier(srcWidth: Double, srcHeight: Double, dstWidth: Double, dstHeight: Double, scale: Scale): Double
fun computeSizeMultiplier(srcWidth: Float, srcHeight: Float, dstWidth: Float, dstHeight: Float, scale: Scale): Float

fun computeSizeMultiplier(srcWidth: Int, srcHeight: Int, dstWidth: Int, dstHeight: Int, scale: Scale): Double

Calculate the percentage to multiply the source dimensions by to fit/fill the destination dimensions while preserving aspect ratio.