'How to increase capture default camera image quality

I am using default camera and capturing image. we have converted Base64 image after converting image quality is blur and image size getting very low below 50kb. Can you please help how to increase image better quality with Base64 format. I have attached my code please edit and give solution.

 private val getCameraImage = registerForActivityResult(ActivityResultContracts.TakePicturePreview()) { bitmap ->
    try {
        if (bitmap != null) {
            val byteArrayOutputStream = ByteArrayOutputStream()
            bitmap?.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)
            val byteArray: ByteArray = byteArrayOutputStream.toByteArray()

            encodedPhoto = Base64Utils.encode(byteArray)
            Toast.makeText(this.activity, "Image uploaded successfully", Toast.LENGTH_LONG)
                .show()
            sales_invoice_image.background =
                ContextCompat.getDrawable(requireContext(), R.color.syncBar)
        } else {
            Toast.makeText(this.activity, "Something went wrong, Try again.", Toast.LENGTH_LONG)
                .show()
        }
    } catch (e: NullPointerException) {

    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source