Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private fun prepareImageBase64String(): String {
- val imageStream = activity.contentResolver.openInputStream(mPictureUri)
- val selectedImage: Bitmap = BitmapFactory.decodeStream(imageStream)
- return encodeImage(selectedImage)
- }
- private fun encodeImage(bm: Bitmap): String {
- val byteArrayOutputStream = ByteArrayOutputStream()
- bm.compress(Bitmap.CompressFormat.JPEG, 40, byteArrayOutputStream)
- val bytes = byteArrayOutputStream.toByteArray()
- return Base64.encodeToString(bytes, Base64.DEFAULT)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement