MeshCentralAndroidAgent
MeshCentralAndroidAgent copied to clipboard
users account image not shown if png
so it appears if a users account image in meshcentral is PNG, then its not shown in the app
function getUserImage inside of MeshAgent.kt
if ((ximage != null) && (!ximage.startsWith("data:image/jpeg;base64,"))) { ximage = null; }
fix
if ((ximage != null) &&
(!ximage.startsWith("data:image/jpeg;base64,") &&
!ximage.startsWith("data:image/png;base64,"))) {
ximage = null
}
if (ximage != null) {
try {
// Determine the start index for decoding
val base64Prefix = when {
ximage.startsWith("data:image/jpeg;base64,") -> "data:image/jpeg;base64,"
ximage.startsWith("data:image/png;base64,") -> "data:image/png;base64,"
else -> ""
}
// Decode the image after removing the base64 header
val imageBytes = android.util.Base64.decode(ximage.substring(base64Prefix.length), 0)
xuserImage = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)
// Round the image edges
val imageRounded = Bitmap.createBitmap(xuserImage.width, xuserImage.height, xuserImage.config)
val canvas = Canvas(imageRounded)
val mpaint = Paint()
mpaint.isAntiAlias = true
mpaint.shader = BitmapShader(xuserImage, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)
canvas.drawRoundRect(RectF(0F, 0F, xuserImage.width.toFloat(), xuserImage.height.toFloat()), 32F, 32F, mpaint)
xuserImage.recycle()
xuserImage = imageRounded
} catch (ex: java.lang.Exception) {
// Handle exceptions here
}
}