I have a byteArray which holds the data for a jpeg image.
I am using this to get the bitmap:
try {
val decodedBytes = Base64.decode(imageString, Base64.DEFAULT)
if (decodedBytes.isNotEmpty()) {
val bitMap = BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.size)
Log.i("Newbitmap", decodedBytes.toString())
Log.i("Newbitmap", decodedBytes.size.toString())
} else {
Log.e("Newbitmap", "Decoded bytes array is empty.")
}
} catch (e: Exception) {
e.printStackTrace()
Log.e("Newbitmap", e.toString())
}
But I am getting null for bitMap
with a debug statement: --- Failed to create image decoder with message 'invalid input'
Then I tried with a base64 String to generate the image, tested that string using some online decoders and Python, I was getting the image using online decoders and Python Pillow library. But when I use that exact same string in Android, it’s not working. I can add the base64 string here also but it has around 23k characters, so not adding right now. Let me know If anyone need that.
Thanks in advance