I have a bitmap taken of a Base64 String from my remote database, (encodedImage
is the string representing the image with Base64):
profileImage
/**
* Kotlin method for Bitmap scaling
* @param bitmap the bitmap to be scaled
* @param pixel the target pixel size
* @param width the width
* @param height the height
* @param max the max(height, width)
* @return the scaled bitmap
*/
fun scaleBitmap(bitmap:Bitmap, pixel:Float, width:Int, height:Int, max:Int):Bitmap {
val scale = px / max
val h = Math.round(scale * height)
val w = Math.round(scale * width)
return Bitmap.createScaledBitmap(bitmap, w, h, true)
}