DecodeUtils

object DecodeUtils

A collection of useful utility methods for decoding images.

Functions

calculateInSampleSize
Link copied to clipboard
fun calculateInSampleSize(@Px() srcWidth: Int, @Px() srcHeight: Int, @Px() dstWidth: Int, @Px() 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.
computeSizeMultiplier
Link copied to clipboard
fun computeSizeMultiplier(@Px() srcWidth: Double, @Px() srcHeight: Double, @Px() dstWidth: Double, @Px() dstHeight: Double, scale: Scale): Double
fun computeSizeMultiplier(@Px() srcWidth: Float, @Px() srcHeight: Float, @Px() dstWidth: Float, @Px() dstHeight: Float, scale: Scale): Float
fun computeSizeMultiplier(@Px() srcWidth: Int, @Px() srcHeight: Int, @Px() dstWidth: Int, @Px() dstHeight: Int, scale: Scale): Double
Calculate the percentage to multiply the source dimensions by to fit/fill the destination dimensions while preserving aspect ratio.