I am capturing an image using camerax API image is being captured successfully and then I convert it to bitmap using below method
fun Image.toBitmap(): Bitmap {
val buffer = planes[0].buffer
buffer.rewind()
val bytes = ByteArray(buffer.capacity())
buffer.get(bytes)
return BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
}
this method works perfectly and I succeed to setBitMapImage to image view the issue is that I want to share this captured bitmap image on what's app view intent without saving in storage The below method is what I using to compress the bitmap
private fun btmToPng(){
try {
val baos = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.JPEG, 40, baos)
baos.close()
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
}
but getting this error
Caused by: android.os.TransactionTooLargeException: data parcel size 51917416 bytes