Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This encodes a bitmap in base64
private String encodeImage(Bitmap bitmap) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] byteArray = baos.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment