BitmapUtils

Contains convenient methods for Bitmaps.

Functions

Link copied to clipboard
fun calculateInSampleSize(options: BitmapFactory.Options, reqWidth: Int, reqHeight: Int): Int

Calculates best inSampleSize to fit reqWidth and reqHeight or a bit more

Link copied to clipboard
fun compress(bitmap: Bitmap, format: Bitmap.CompressFormat, quality: Int, file: File?)

Compresses Bitmap to File

Link copied to clipboard
fun createPreview(image: Bitmap?, targetWidth: Int, targetHeight: Int): Bitmap?
fun createPreview(image: ByteArray?, targetWidth: Int, targetHeight: Int): Bitmap?

Create preview from image byte array

fun createPreview(res: Resources?, imageRes: Int, targetWidth: Int, targetHeight: Int): Bitmap?

Create preview from large (nodpi) resource image

Link copied to clipboard

Decodes Bitmap with minimal log output. Accepts null arguments.

Link copied to clipboard

Converts image drawable to Bitmap.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun scaleIfNeeded(image: Bitmap, maxHeight: Int, maxWidth: Int): Bitmap

Scales bitmap with saved aspectRatio