Skip to content

Instantly share code, notes, and snippets.

@zurche
Created February 13, 2017 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zurche/d952293f4027f7ddaec0071b76352101 to your computer and use it in GitHub Desktop.
Save zurche/d952293f4027f7ddaec0071b76352101 to your computer and use it in GitHub Desktop.
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