Created
July 1, 2017 20:23
-
-
Save Vikctar/135c49942f28fc2180866573eac50a67 to your computer and use it in GitHub Desktop.
convert bitmap to string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getStringImage(Bitmap bmp) { | |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); | |
bmp.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); | |
byte[] imageBytes = byteArrayOutputStream.toByteArray(); | |
return "data:image/jpeg;base64," + Base64.encodeToString(imageBytes, Base64.DEFAULT); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I appended the raw string to the base64 one since the server was expecting the string to start like that.
You can remove it and just return a base64