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.
computePixelSize
Link copied to clipboard
fun computePixelSize(srcWidth: Int, srcHeight: Int, dstSize: Size, scale: Scale): PixelSize
Calculate the pixel size required to fit/fill the source dimensions inside the destination size while preserving aspect ratio.
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.
isAnimatedHeif
Link copied to clipboard
fun isAnimatedHeif(source: BufferedSource): Boolean
Return true if the source contains an animated HEIF image sequence.
isAnimatedWebP
Link copied to clipboard
fun isAnimatedWebP(source: BufferedSource): Boolean
Return true if the source contains an animated WebP image.
isGif
Link copied to clipboard
fun isGif(source: BufferedSource): Boolean
Return true if the source contains a GIF image.
isHeif
Link copied to clipboard
fun isHeif(source: BufferedSource): Boolean
Return true if the source contains an HEIF image.
isWebP
Link copied to clipboard
fun isWebP(source: BufferedSource): Boolean
Return true if the source contains a WebP image.