Skip to content

Instantly share code, notes, and snippets.

@h4h13
Created January 9, 2017 07:49
Show Gist options
  • Save h4h13/f0f2dc4e460e1766b1720de8c7db175c to your computer and use it in GitHub Desktop.
Save h4h13/f0f2dc4e460e1766b1720de8c7db175c to your computer and use it in GitHub Desktop.
Converters
public static String encodeBitmapTobase64(Bitmap image) {
Bitmap immage = image;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
immage.compress(CompressFormat.PNG, 100, baos);
String imageEncoded = Base64.encodeToString(baos.toByteArray(), 0);
Log.d("Image Log:", imageEncoded);
return imageEncoded;
}
public static Bitmap decodeBase64ToBitmap(String input) {
byte[] decodedByte = Base64.decode(input, 0);
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment